Set up pre-commit framework with ruff (backend) and ESLint/Prettier/tsc (frontend) hooks to catch issues locally before CI. Auto-format all frontend files with Prettier to comply with the new check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
809 B
TypeScript
29 lines
809 B
TypeScript
import { api } from './client'
|
|
import type { Game, Route, RouteEncounterDetail } 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[]> {
|
|
// Use flat=true to get all routes in a flat list
|
|
// The frontend organizes them into hierarchy based on parentRouteId
|
|
return api.get(`/games/${gameId}/routes?flat=true`)
|
|
}
|
|
|
|
export function getRoutePokemon(
|
|
routeId: number,
|
|
gameId?: number
|
|
): Promise<RouteEncounterDetail[]> {
|
|
const params = gameId != null ? `?game_id=${gameId}` : ''
|
|
return api.get(`/routes/${routeId}/pokemon${params}`)
|
|
}
|