diff --git a/frontend-sba/pages/games/index.vue b/frontend-sba/pages/games/index.vue index df4760f..c9c2b2b 100755 --- a/frontend-sba/pages/games/index.vue +++ b/frontend-sba/pages/games/index.vue @@ -7,12 +7,21 @@ View and manage your active and completed games

- - Create New Game - +
+ + + Create New Game + +
@@ -188,11 +197,13 @@ definePageMeta({ const activeTab = ref<'active' | 'completed'>('active') const config = useRuntimeConfig() const authStore = useAuthStore() +const router = useRouter() // Games data const games = ref([]) const loading = ref(true) const error = ref(null) +const isCreatingQuickGame = ref(false) // Fetch games from API (client-side only) async function fetchGames() { @@ -216,6 +227,36 @@ async function fetchGames() { } } +// Quick-create a demo game with pre-configured lineups +async function handleQuickCreate() { + try { + isCreatingQuickGame.value = true + error.value = null + + console.log('[Games Page] Quick-creating demo game...') + + const response = await $fetch<{ game_id: string; message: string; status: string }>( + `${config.public.apiUrl}/api/games/quick-create`, + { + method: 'POST', + headers: { + Authorization: `Bearer ${authStore.token}` + } + } + ) + + console.log('[Games Page] Quick-create response:', response) + + // Redirect to game page + router.push(`/games/${response.game_id}`) + } catch (err: any) { + console.error('[Games Page] Quick-create failed:', err) + error.value = err.data?.detail || err.message || 'Failed to create demo game' + } finally { + isCreatingQuickGame.value = false + } +} + // Filter games by status const activeGames = computed(() => { return games.value?.filter(g => g.status === 'active' || g.status === 'pending') || []