histories are a little messed, will change the logic in the future (techdebt)

This commit is contained in:
Edd
2025-12-30 01:49:39 +00:00
parent c456c9482f
commit 4f391e3638
12 changed files with 726 additions and 239 deletions
+15 -2
View File
@@ -53,12 +53,10 @@ export const useAPIStore = defineStore('api', () => {
delete axios.defaults.headers.common['Authorization']
}
// Users
const getAuthUser = () => {
return axios.get(`${API_BASE_URL}/users/me`)
}
//Games
const getGames = (resetPagination = false) => {
if (resetPagination) {
gameQueryParameters.value.page = 1
@@ -78,11 +76,26 @@ export const useAPIStore = defineStore('api', () => {
return axios.get(`${API_BASE_URL}/games?${queryParams}`)
}
const getCurrentUserMatches = (params = {}) => {
const queryParams = new URLSearchParams({
page: params.page || 1,
...(params.type && { type: params.type }),
...(params.status && { status: params.status }),
sort_by: params.sort || 'began_at',
sort_direction: params.direction || 'desc',
}).toString()
console.log(params, queryParams)
return axios.get(`${API_BASE_URL}/users/${authStore.currentUserID}/matches?${queryParams}`)
}
return {
postLogin,
postLogout,
getAuthUser,
getGames,
getCurrentUserMatches,
gameQueryParameters,
}
})