2026-02-05 18:36:19 +01:00
|
|
|
import { api } from './client'
|
|
|
|
|
import type {
|
|
|
|
|
Game,
|
|
|
|
|
Route,
|
|
|
|
|
Pokemon,
|
|
|
|
|
RouteEncounterDetail,
|
|
|
|
|
CreateGameInput,
|
|
|
|
|
UpdateGameInput,
|
|
|
|
|
CreateRouteInput,
|
|
|
|
|
UpdateRouteInput,
|
|
|
|
|
RouteReorderItem,
|
|
|
|
|
CreatePokemonInput,
|
|
|
|
|
UpdatePokemonInput,
|
|
|
|
|
BulkImportResult,
|
2026-02-06 11:19:05 +01:00
|
|
|
PaginatedPokemon,
|
2026-02-05 18:36:19 +01:00
|
|
|
CreateRouteEncounterInput,
|
|
|
|
|
UpdateRouteEncounterInput,
|
Improve admin panel UX with toasts, evolution CRUD, sorting, drag-and-drop, and responsive layout
Add sonner toast notifications to all mutations, evolution management backend
(CRUD endpoints with search/pagination) and frontend (form modal with pokemon
selector, paginated list page), sortable AdminTable columns (Region/Gen/Year
on Games), drag-and-drop route reordering via @dnd-kit, skeleton loading states,
card-styled table wrappers, and responsive mobile nav in AdminLayout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:09:27 +01:00
|
|
|
EvolutionAdmin,
|
|
|
|
|
PaginatedEvolutions,
|
|
|
|
|
CreateEvolutionInput,
|
|
|
|
|
UpdateEvolutionInput,
|
2026-02-05 18:36:19 +01:00
|
|
|
} from '../types'
|
|
|
|
|
|
|
|
|
|
// Games
|
|
|
|
|
export const createGame = (data: CreateGameInput) =>
|
|
|
|
|
api.post<Game>('/games', data)
|
|
|
|
|
|
|
|
|
|
export const updateGame = (id: number, data: UpdateGameInput) =>
|
|
|
|
|
api.put<Game>(`/games/${id}`, data)
|
|
|
|
|
|
|
|
|
|
export const deleteGame = (id: number) =>
|
|
|
|
|
api.del(`/games/${id}`)
|
|
|
|
|
|
|
|
|
|
// Routes
|
|
|
|
|
export const createRoute = (gameId: number, data: CreateRouteInput) =>
|
|
|
|
|
api.post<Route>(`/games/${gameId}/routes`, data)
|
|
|
|
|
|
|
|
|
|
export const updateRoute = (gameId: number, routeId: number, data: UpdateRouteInput) =>
|
|
|
|
|
api.put<Route>(`/games/${gameId}/routes/${routeId}`, data)
|
|
|
|
|
|
|
|
|
|
export const deleteRoute = (gameId: number, routeId: number) =>
|
|
|
|
|
api.del(`/games/${gameId}/routes/${routeId}`)
|
|
|
|
|
|
|
|
|
|
export const reorderRoutes = (gameId: number, routes: RouteReorderItem[]) =>
|
|
|
|
|
api.put<Route[]>(`/games/${gameId}/routes/reorder`, { routes })
|
|
|
|
|
|
|
|
|
|
// Pokemon
|
|
|
|
|
export const listPokemon = (search?: string, limit = 50, offset = 0) => {
|
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
|
if (search) params.set('search', search)
|
|
|
|
|
params.set('limit', String(limit))
|
|
|
|
|
params.set('offset', String(offset))
|
2026-02-06 11:19:05 +01:00
|
|
|
return api.get<PaginatedPokemon>(`/pokemon?${params}`)
|
2026-02-05 18:36:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createPokemon = (data: CreatePokemonInput) =>
|
|
|
|
|
api.post<Pokemon>('/pokemon', data)
|
|
|
|
|
|
|
|
|
|
export const updatePokemon = (id: number, data: UpdatePokemonInput) =>
|
|
|
|
|
api.put<Pokemon>(`/pokemon/${id}`, data)
|
|
|
|
|
|
|
|
|
|
export const deletePokemon = (id: number) =>
|
|
|
|
|
api.del(`/pokemon/${id}`)
|
|
|
|
|
|
|
|
|
|
export const bulkImportPokemon = (items: Array<{ nationalDex: number; name: string; types: string[]; spriteUrl?: string | null }>) =>
|
|
|
|
|
api.post<BulkImportResult>('/pokemon/bulk-import', items)
|
|
|
|
|
|
Improve admin panel UX with toasts, evolution CRUD, sorting, drag-and-drop, and responsive layout
Add sonner toast notifications to all mutations, evolution management backend
(CRUD endpoints with search/pagination) and frontend (form modal with pokemon
selector, paginated list page), sortable AdminTable columns (Region/Gen/Year
on Games), drag-and-drop route reordering via @dnd-kit, skeleton loading states,
card-styled table wrappers, and responsive mobile nav in AdminLayout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:09:27 +01:00
|
|
|
// Evolutions
|
|
|
|
|
export const listEvolutions = (search?: string, limit = 50, offset = 0) => {
|
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
|
if (search) params.set('search', search)
|
|
|
|
|
params.set('limit', String(limit))
|
|
|
|
|
params.set('offset', String(offset))
|
|
|
|
|
return api.get<PaginatedEvolutions>(`/evolutions?${params}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createEvolution = (data: CreateEvolutionInput) =>
|
|
|
|
|
api.post<EvolutionAdmin>('/evolutions', data)
|
|
|
|
|
|
|
|
|
|
export const updateEvolution = (id: number, data: UpdateEvolutionInput) =>
|
|
|
|
|
api.put<EvolutionAdmin>(`/evolutions/${id}`, data)
|
|
|
|
|
|
|
|
|
|
export const deleteEvolution = (id: number) =>
|
|
|
|
|
api.del(`/evolutions/${id}`)
|
|
|
|
|
|
2026-02-05 18:36:19 +01:00
|
|
|
// Route Encounters
|
|
|
|
|
export const addRouteEncounter = (routeId: number, data: CreateRouteEncounterInput) =>
|
|
|
|
|
api.post<RouteEncounterDetail>(`/routes/${routeId}/pokemon`, data)
|
|
|
|
|
|
|
|
|
|
export const updateRouteEncounter = (routeId: number, encounterId: number, data: UpdateRouteEncounterInput) =>
|
|
|
|
|
api.put<RouteEncounterDetail>(`/routes/${routeId}/pokemon/${encounterId}`, data)
|
|
|
|
|
|
|
|
|
|
export const removeRouteEncounter = (routeId: number, encounterId: number) =>
|
|
|
|
|
api.del(`/routes/${routeId}/pokemon/${encounterId}`)
|