histories are a little messed, will change the logic in the future (techdebt)
This commit is contained in:
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user