Pokemon edit modal now shows three tabs (Details, Evolutions, Encounters)
instead of a single long form. Evolution chain entries are clickable to
open the EvolutionFormModal for direct editing. Encounter locations link
to admin route detail pages. Create mode shows only the form (no tabs).
Backend adds GET /pokemon/{id}/encounter-locations (grouped by game) and
GET /pokemon/{id}/evolution-chain (BFS family discovery). Extracts
formatEvolutionMethod to shared utility.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
1014 B
TypeScript
35 lines
1014 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,
|
|
})
|
|
}
|