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:
30
frontend/src/api/runs.ts
Normal file
30
frontend/src/api/runs.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { api } from './client'
|
||||
import type {
|
||||
NuzlockeRun,
|
||||
RunDetail,
|
||||
CreateRunInput,
|
||||
UpdateRunInput,
|
||||
} from '../types/game'
|
||||
|
||||
export function getRuns(): Promise<NuzlockeRun[]> {
|
||||
return api.get('/runs')
|
||||
}
|
||||
|
||||
export function getRun(id: number): Promise<RunDetail> {
|
||||
return api.get(`/runs/${id}`)
|
||||
}
|
||||
|
||||
export function createRun(data: CreateRunInput): Promise<NuzlockeRun> {
|
||||
return api.post('/runs', data)
|
||||
}
|
||||
|
||||
export function updateRun(
|
||||
id: number,
|
||||
data: UpdateRunInput,
|
||||
): Promise<NuzlockeRun> {
|
||||
return api.patch(`/runs/${id}`, data)
|
||||
}
|
||||
|
||||
export function deleteRun(id: number): Promise<void> {
|
||||
return api.del(`/runs/${id}`)
|
||||
}
|
||||
Reference in New Issue
Block a user