🔄 Refactor state management to use useAsyncState for tournaments and loading states
This commit is contained in:
@@ -402,6 +402,7 @@ import { ref, computed, watch, onMounted } from 'vue';
|
|||||||
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
||||||
import { useChallongeOAuth } from '../composables/useChallongeOAuth.js';
|
import { useChallongeOAuth } from '../composables/useChallongeOAuth.js';
|
||||||
import { useChallongeClientCredentials } from '../composables/useChallongeClientCredentials.js';
|
import { useChallongeClientCredentials } from '../composables/useChallongeClientCredentials.js';
|
||||||
|
import { useAsyncState } from '../composables/useAsyncState.js';
|
||||||
import {
|
import {
|
||||||
createChallongeV1Client,
|
createChallongeV1Client,
|
||||||
createChallongeV2Client,
|
createChallongeV2Client,
|
||||||
@@ -426,14 +427,17 @@ const {
|
|||||||
// API Configuration
|
// API Configuration
|
||||||
const apiVersion = ref('v2.1'); // 'v1' or 'v2.1'
|
const apiVersion = ref('v2.1'); // 'v1' or 'v2.1'
|
||||||
|
|
||||||
// State
|
// State management with useAsyncState
|
||||||
const loading = ref(false);
|
const tournamentListState = useAsyncState();
|
||||||
const loadingMore = ref(false);
|
const loadMoreState = useAsyncState();
|
||||||
const error = ref(null);
|
const tournamentDetailsState = useAsyncState();
|
||||||
const tournaments = ref(null);
|
|
||||||
|
// Destructure for template usage
|
||||||
|
const { data: tournaments, isLoading: loading, error } = tournamentListState;
|
||||||
|
const { isLoading: loadingMore } = loadMoreState;
|
||||||
|
|
||||||
const searchQuery = ref('');
|
const searchQuery = ref('');
|
||||||
const expandedTournamentId = ref(null);
|
const expandedTournamentId = ref(null);
|
||||||
const tournamentDetails = ref(null);
|
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
const currentPage = ref(1);
|
const currentPage = ref(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user