Spaces:
Running
Running
File size: 738 Bytes
94004a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { apiJson, apiPost, apiFetch } from './client';
import type { ProjectSummary, ProjectDetail } from './types';
export async function listProjects(): Promise<ProjectSummary[]> {
return apiJson<ProjectSummary[]>('/projects');
}
export async function saveProject(body: Record<string, unknown>, id?: string): Promise<ProjectDetail> {
if (id) return apiPost<ProjectDetail>(`/projects/${id}`, body, { method: 'PUT' });
return apiPost<ProjectDetail>('/projects', body);
}
export async function loadProject(id: string): Promise<ProjectDetail> {
return apiJson<ProjectDetail>(`/projects/${id}`);
}
export async function deleteProject(id: string): Promise<Response> {
return apiFetch(`/projects/${id}`, { method: 'DELETE' });
}
|