Add Pokemon detail card with tabbed encounter/evolution views

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>
This commit is contained in:
2026-02-08 14:03:43 +01:00
parent f09b8213fd
commit a01d01c565
10 changed files with 482 additions and 94 deletions

View File

@@ -1,11 +1,11 @@
---
# nuzlocke-tracker-dyzh
title: Click-to-edit pattern across admin tables
status: todo
status: completed
type: feature
priority: high
created_at: 2026-02-08T12:32:53Z
updated_at: 2026-02-08T12:35:03Z
updated_at: 2026-02-08T12:45:17Z
parent: nuzlocke-tracker-iu5b
blocking:
- nuzlocke-tracker-fxi7

View File

@@ -1,11 +1,11 @@
---
# nuzlocke-tracker-fxi7
title: Pokemon detail card with encounters and evolution chain
status: todo
status: completed
type: feature
priority: high
created_at: 2026-02-08T12:33:05Z
updated_at: 2026-02-08T12:33:05Z
updated_at: 2026-02-08T12:53:13Z
parent: nuzlocke-tracker-iu5b
---
@@ -16,12 +16,28 @@ When viewing/editing a Pokemon in the admin panel, show contextual information a
1. Editable fields (name, types, dex number, sprite, etc.)
2. **Encounter locations**: A list of routes/games where this pokemon appears as a route encounter. Grouped by game, showing route name + encounter method + levels.
3. **Evolution chain**: Visual display of the pokemon's evolution family — predecessors and successors with triggers (level, item, trade, etc.)
- Encounter locations and evolution chain are read-only informational sections
- Encounter locations link to the route detail page in admin for quick navigation
- Evolution chain entries are clickable to open the EvolutionFormModal for direct editing
## Backend support
- Encounters by pokemon: May need a new endpoint or can query route_encounters filtered by pokemon_id
- Evolution chain: Can reuse existing /pokemon/{id}/evolutions endpoint, but may need a 'full chain' variant that shows the complete family tree (not just direct evolutions from this pokemon)
## Implementation
### Tabbed modal (edit mode)
In edit mode, the PokemonFormModal uses three tabs instead of a single scrolling view:
- **Details** — the form fields (PokeAPI ID, name, types, etc.) with Save/Delete/Cancel footer
- **Evolutions** — clickable evolution chain rows that open a stacked EvolutionFormModal for direct editing
- **Encounters** — encounter locations grouped by game, with route names linking to admin route detail pages
In create mode, no tabs are shown (just the form fields).
### Backend endpoints
- `GET /pokemon/{id}/encounter-locations` — returns encounters grouped by game with route/game names eagerly loaded
- `GET /pokemon/{id}/evolution-chain` — BFS to find full evolution family, returns all edges with from/to Pokemon
### Frontend
- New types: `PokemonEncounterLocationItem`, `PokemonEncounterLocation`
- New API functions: `fetchPokemonEncounterLocations`, `fetchPokemonEvolutionChain`
- New hooks: `usePokemonEncounterLocations`, `usePokemonEvolutionChain`
- Extracted `formatEvolutionMethod` to shared `utils/formatEvolution.ts`
## Notes
- This helps the admin quickly verify data completeness — 'is this pokemon assigned to the right routes?' and 'are its evolutions set up correctly?'