kin: KIN-UI-003 Консистентная обработка ошибок в del() — использовать throwApiError

This commit is contained in:
Gros Frumos 2026-03-16 17:44:49 +02:00
parent fc13245c93
commit 531275e4ce
5 changed files with 112 additions and 35 deletions

View file

@ -48,7 +48,8 @@ async function post<T>(path: string, body: unknown): Promise<T> {
async function del<T>(path: string): Promise<T> {
const res = await fetch(`${BASE}${path}`, { method: 'DELETE' })
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`)
if (!res.ok) await throwApiError(res)
if (res.status === 204) return undefined as T
return res.json()
}
@ -270,6 +271,8 @@ export const api = {
post<DeployResult>(`/projects/${projectId}/deploy`, {}),
syncObsidian: (projectId: string) =>
post<ObsidianSyncResult>(`/projects/${projectId}/sync/obsidian`, {}),
deleteProject: (id: string) =>
del<void>(`/projects/${id}`),
deleteDecision: (projectId: string, decisionId: number) =>
del<{ deleted: number }>(`/projects/${projectId}/decisions/${decisionId}`),
createDecision: (data: { project_id: string; type: string; title: string; description: string; category?: string; tags?: string[] }) =>