Added corrections to user profile and admin match and game history

This commit is contained in:
2026-01-03 00:41:24 +00:00
parent 1a7916a836
commit 894a38bb27
6 changed files with 1240 additions and 706 deletions
File diff suppressed because it is too large Load Diff
+16 -8
View File
@@ -1199,7 +1199,6 @@ const fetchData = async () => {
})
games.value.push(...newData)
}
if (isMatch) {
const response = await apiStore.getCurrentUserMatches(gameMatchParams)
const apiMatches = response.data.data
@@ -1212,21 +1211,30 @@ const fetchData = async () => {
if (game.is_draw) outcome = 'draw'
else if (game.winner_user_id === authStore.currentUser.id) outcome = 'win'
let coinAmount = 0
if (game.total_reward) {
coinAmount = parseFloat(game.total_reward)
// LÓGICA CORRIGIDA PARA COINS
// A API devolve 'stake' (o valor que cada um apostou)
let stakeAmount = 0
if (game.stake) {
stakeAmount = parseFloat(game.stake)
}
const displayAmount = outcome === 'loss' ? coinAmount / 2 : coinAmount
// Se Ganhou: O lucro é o valor da stake (ex: apostou 10, recebeu 20, lucro +10)
// Se Perdeu: O prejuízo é o valor da stake (ex: -10)
// Se Empate: Normalmente devolve-se a aposta, por isso é 0 (ou ajusta conforme a tua regra)
let displayAmount = 0
if (outcome === 'win') {
displayAmount = stakeAmount // Ganhou a aposta do outro
} else if (outcome === 'loss') {
displayAmount = stakeAmount // Perdeu a sua aposta (o sinal negativo é adicionado no HTML)
}
return {
id: game.id,
variant: `Type ${game.type}`,
outcome: outcome,
opponent: opponent?.nickname || 'Unknown Player',
amount: displayAmount,
amount: displayAmount, // Valor corrigido
duration: `${Math.floor(game.total_time / 60)}m ${game.total_time % 60}s`,
began_at: game.began_at,
details: {
+17 -1
View File
@@ -174,9 +174,24 @@ export const useAPIStore = defineStore('api', () => {
...(params.sort_direction == 'asc' && { sort_direction: 'asc' }),
...(params.type && { type: params.type }),
}).toString()
return axios.get(`${API_BASE_URL}/games?${queryParams}`)
}
const getAdminMatches = (params = {}) => {
const queryParams = new URLSearchParams({
page: params.page || 1,
...(params.type && { type: params.type }),
...(params.outcome && { outcome: params.outcome }),
...(params.date_from && { date_from: params.date_from }),
...(params.date_to && { date_to: params.date_to }),
sort_by: params.sort_by || 'began_at',
sort_direction: params.sort_direction || 'desc',
}).toString()
return axios.get(`${API_BASE_URL}/matches?${queryParams}`)
}
const postAdmin = async (credentials) => {
return axios.post(`${API_BASE_URL}/admin/users`, credentials)
}
@@ -199,7 +214,8 @@ export const useAPIStore = defineStore('api', () => {
deleteUser,
getAdminTransactions,
getAdminGames,
getAdminMatches,
postAdmin,
gameQueryParameters,
}
})
})