2026-02-05 15:09:14 +01:00
|
|
|
import { api } from './client'
|
2026-02-05 15:28:50 +01:00
|
|
|
import type { Game, Route, RouteEncounterDetail } from '../types/game'
|
2026-02-05 15:09:14 +01:00
|
|
|
|
|
|
|
|
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[]> {
|
2026-02-06 11:07:45 +01:00
|
|
|
// 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`)
|
2026-02-05 15:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-05 15:28:50 +01:00
|
|
|
export function getRoutePokemon(routeId: number): Promise<RouteEncounterDetail[]> {
|
2026-02-05 15:09:14 +01:00
|
|
|
return api.get(`/routes/${routeId}/pokemon`)
|
|
|
|
|
}
|