From 5e7e411a522400b48c4a7fffed52033789d5aa25 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 02:02:56 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Refactor=20state=20management=20?= =?UTF-8?q?to=20use=20`useAsyncState`=20for=20tournaments=20and=20loading?= =?UTF-8?q?=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokedex.online/src/views/ChallongeTest.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/code/websites/pokedex.online/src/views/ChallongeTest.vue b/code/websites/pokedex.online/src/views/ChallongeTest.vue index f7a05b8..e7c264a 100644 --- a/code/websites/pokedex.online/src/views/ChallongeTest.vue +++ b/code/websites/pokedex.online/src/views/ChallongeTest.vue @@ -402,6 +402,7 @@ import { ref, computed, watch, onMounted } from 'vue'; import { useChallongeApiKey } from '../composables/useChallongeApiKey.js'; import { useChallongeOAuth } from '../composables/useChallongeOAuth.js'; import { useChallongeClientCredentials } from '../composables/useChallongeClientCredentials.js'; +import { useAsyncState } from '../composables/useAsyncState.js'; import { createChallongeV1Client, createChallongeV2Client, @@ -426,14 +427,17 @@ const { // API Configuration const apiVersion = ref('v2.1'); // 'v1' or 'v2.1' -// State -const loading = ref(false); -const loadingMore = ref(false); -const error = ref(null); -const tournaments = ref(null); +// State management with useAsyncState +const tournamentListState = useAsyncState(); +const loadMoreState = useAsyncState(); +const tournamentDetailsState = useAsyncState(); + +// Destructure for template usage +const { data: tournaments, isLoading: loading, error } = tournamentListState; +const { isLoading: loadingMore } = loadMoreState; + const searchQuery = ref(''); const expandedTournamentId = ref(null); -const tournamentDetails = ref(null); // Pagination const currentPage = ref(1);