refactor: modularize API client by splitting resources into individual files and standardizing HTTP request handling.
This commit is contained in:
17
apps/frontend/src/lib/api/resources/courts.ts
Normal file
17
apps/frontend/src/lib/api/resources/courts.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { Court, CreateCourtInput, UpdateCourtInput } from '@repo/api-contract';
|
||||
import { http } from '../http';
|
||||
|
||||
export async function listByComplex(complexId: string) {
|
||||
const response = await http.get<Court[]>(`/api/courts/complex/${complexId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function create(complexId: string, payload: CreateCourtInput) {
|
||||
const response = await http.post<Court>(`/api/courts/complex/${complexId}`, payload);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function update(id: string, payload: UpdateCourtInput) {
|
||||
const response = await http.patch<Court>(`/api/courts/${id}`, payload);
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user