Files
nuzlocke-tracker/frontend/src/hooks/usePokemon.ts
Julian Tabel 2963f16aa4
All checks were successful
CI / backend-lint (push) Successful in 9s
CI / frontend-lint (push) Successful in 33s
Add pre-commit hooks for linting and formatting
Set up pre-commit framework with ruff (backend) and ESLint/Prettier/tsc
(frontend) hooks to catch issues locally before CI. Auto-format all
frontend files with Prettier to comply with the new check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 16:41:24 +01:00

40 lines
1023 B
TypeScript

import { useQuery } from '@tanstack/react-query'
import {
getPokemon,
fetchPokemonFamilies,
fetchPokemonEncounterLocations,
fetchPokemonEvolutionChain,
} from '../api/pokemon'
export function usePokemon(id: number | null) {
return useQuery({
queryKey: ['pokemon', id],
queryFn: () => getPokemon(id!),
enabled: id !== null,
})
}
export function usePokemonFamilies() {
return useQuery({
queryKey: ['pokemon', 'families'],
queryFn: fetchPokemonFamilies,
staleTime: Infinity,
})
}
export function usePokemonEncounterLocations(pokemonId: number | null) {
return useQuery({
queryKey: ['pokemon', pokemonId, 'encounter-locations'],
queryFn: () => fetchPokemonEncounterLocations(pokemonId!),
enabled: pokemonId !== null,
})
}
export function usePokemonEvolutionChain(pokemonId: number | null) {
return useQuery({
queryKey: ['pokemon', pokemonId, 'evolution-chain'],
queryFn: () => fetchPokemonEvolutionChain(pokemonId!),
enabled: pokemonId !== null,
})
}