🎮 Refactor tournament details handling to use tournamentDetailsState with error management and remove redundant assignments
This commit is contained in:
@@ -658,27 +658,26 @@ async function changePerPage(newLimit) {
|
||||
async function toggleTournamentDetails(tournamentId) {
|
||||
if (expandedTournamentId.value === tournamentId) {
|
||||
expandedTournamentId.value = null;
|
||||
tournamentDetails.value = null;
|
||||
tournamentDetailsState.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
expandedTournamentId.value = tournamentId;
|
||||
tournamentDetails.value = null;
|
||||
|
||||
try {
|
||||
await tournamentDetailsState.execute(async () => {
|
||||
if (apiVersion.value === 'v1') {
|
||||
const result = await client.value.tournaments.get(tournamentId, {
|
||||
return await client.value.tournaments.get(tournamentId, {
|
||||
includeParticipants: true,
|
||||
includeMatches: true
|
||||
});
|
||||
tournamentDetails.value = result;
|
||||
} else {
|
||||
// v2.1 get tournament
|
||||
const result = await client.value.tournaments.get(tournamentId);
|
||||
tournamentDetails.value = result;
|
||||
return await client.value.tournaments.get(tournamentId);
|
||||
}
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
});
|
||||
|
||||
// Reset expanded state if there was an error
|
||||
if (tournamentDetailsState.error.value) {
|
||||
expandedTournamentId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user