- Evolution model with trigger, level, item, and condition fields
- Encounter.current_pokemon_id tracks evolved species separately
- Alembic migration for evolutions table and current_pokemon_id column
- Seed pipeline loads evolution data with manual overrides
- GET /pokemon/{id}/evolutions and PATCH /encounters/{id} endpoints
- Evolve button in StatusChangeModal with evolution method details
- PokemonCard shows evolved species with "Originally" label
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import {
|
|
createEncounter,
|
|
updateEncounter,
|
|
deleteEncounter,
|
|
fetchEvolutions,
|
|
} from '../api/encounters'
|
|
import type { CreateEncounterInput, UpdateEncounterInput } from '../types/game'
|
|
|
|
export function useCreateEncounter(runId: number) {
|
|
const queryClient = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: (data: CreateEncounterInput) => createEncounter(runId, data),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['runs', runId] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useUpdateEncounter(runId: number) {
|
|
const queryClient = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: ({
|
|
id,
|
|
data,
|
|
}: {
|
|
id: number
|
|
data: UpdateEncounterInput
|
|
}) => updateEncounter(id, data),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['runs', runId] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useDeleteEncounter(runId: number) {
|
|
const queryClient = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: (id: number) => deleteEncounter(id),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['runs', runId] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useEvolutions(pokemonId: number | null) {
|
|
return useQuery({
|
|
queryKey: ['evolutions', pokemonId],
|
|
queryFn: () => fetchEvolutions(pokemonId!),
|
|
enabled: pokemonId !== null,
|
|
})
|
|
}
|