Files
nuzlocke-tracker/frontend/src/hooks/useGames.ts
Julian Tabel 3e88ba50fa Add version groups to share routes and boss battles across games
Routes and boss battles now belong to a version_group instead of
individual games, so paired versions (e.g. Red/Blue, Gold/Silver)
share the same route structure and boss battles. Route encounters
gain a game_id column to support game-specific encounter tables
within a shared route. Includes migration, updated seeds, API
changes, and frontend type updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 12:07:42 +01:00

33 lines
803 B
TypeScript

import { useQuery } from '@tanstack/react-query'
import { getGames, getGame, getGameRoutes, getRoutePokemon } from '../api/games'
export function useGames() {
return useQuery({
queryKey: ['games'],
queryFn: getGames,
})
}
export function useGame(id: number) {
return useQuery({
queryKey: ['games', id],
queryFn: () => getGame(id),
})
}
export function useGameRoutes(gameId: number | null) {
return useQuery({
queryKey: ['games', gameId, 'routes'],
queryFn: () => getGameRoutes(gameId!),
enabled: gameId !== null,
})
}
export function useRoutePokemon(routeId: number | null, gameId?: number) {
return useQuery({
queryKey: ['routes', routeId, 'pokemon', gameId],
queryFn: () => getRoutePokemon(routeId!, gameId),
enabled: routeId !== null,
})
}