diff --git a/frontend/src/api/batchApi.ts b/frontend/src/api/batchApi.ts index 03b247e..05d0845 100644 --- a/frontend/src/api/batchApi.ts +++ b/frontend/src/api/batchApi.ts @@ -26,6 +26,16 @@ async function putJson(url: string, body?: unknown): Promise { return res.json(); } +async function patchJson(url: string, body?: unknown): Promise { + const res = await fetch(url, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: body ? JSON.stringify(body) : undefined, + }); + if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); + return res.json(); +} + async function deleteJson(url: string): Promise { const res = await fetch(url, { method: 'DELETE' }); if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); @@ -400,7 +410,7 @@ export const batchApi = { deleteJson<{ success: boolean; message: string }>(`${BASE}/schedules/${jobName}`), toggleSchedule: (jobName: string, active: boolean) => - postJson<{ success: boolean; message: string; data?: ScheduleResponse }>( + patchJson<{ success: boolean; message: string; data?: ScheduleResponse }>( `${BASE}/schedules/${jobName}/toggle`, { active }), // Timeline