Files
nuzlocke-tracker/frontend/src/hooks/useGames.ts
Julian Tabel 993ad09d9c
All checks were successful
CI / backend-lint (push) Successful in 10s
CI / actions-lint (push) Successful in 14s
CI / frontend-lint (push) Successful in 22s
Add type restriction rule (monolocke)
Adds allowedTypes: string[] to NuzlockeRules. When set, the encounter
selector hides non-matching Pokemon and the routes endpoint filters out
routes with no matching encounters, so only eligible locations appear.

Type picker UI in RulesConfiguration; active restriction shown in
RuleBadges. Backend accepts allowed_types query param and joins through
RouteEncounter.pokemon to filter by type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 12:22:05 +01:00

33 lines
856 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, allowedTypes?: string[]) {
return useQuery({
queryKey: ['games', gameId, 'routes', allowedTypes],
queryFn: () => getGameRoutes(gameId!, allowedTypes),
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,
})
}