🔄 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 { 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);
|
||||
|
||||
Reference in New Issue
Block a user