Add frontend API client and TanStack Query hooks
Install @tanstack/react-query, create a fetch-based API client with typed functions for all endpoints, and add query/mutation hooks for games, pokemon, runs, and encounters. Includes Vite dev proxy for /api and QueryClientProvider setup. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
22
frontend/src/api/games.ts
Normal file
22
frontend/src/api/games.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { api } from './client'
|
||||
import type { Game, Route, RouteEncounter } from '../types/game'
|
||||
|
||||
export interface GameDetail extends Game {
|
||||
routes: Route[]
|
||||
}
|
||||
|
||||
export function getGames(): Promise<Game[]> {
|
||||
return api.get('/games')
|
||||
}
|
||||
|
||||
export function getGame(id: number): Promise<GameDetail> {
|
||||
return api.get(`/games/${id}`)
|
||||
}
|
||||
|
||||
export function getGameRoutes(gameId: number): Promise<Route[]> {
|
||||
return api.get(`/games/${gameId}/routes`)
|
||||
}
|
||||
|
||||
export function getRoutePokemon(routeId: number): Promise<RouteEncounter[]> {
|
||||
return api.get(`/routes/${routeId}/pokemon`)
|
||||
}
|
||||
Reference in New Issue
Block a user