fix(schedule): 스케줄 toggle API 메서드 불일치 수정 (#6) #8

병합
HYOJIN bugfix/ISSUE-6-schedule-update-method 에서 develop 로 1 commits 를 머지했습니다 2026-03-25 08:40:06 +09:00

파일 보기

@ -26,6 +26,16 @@ async function putJson<T>(url: string, body?: unknown): Promise<T> {
return res.json(); return res.json();
} }
async function patchJson<T>(url: string, body?: unknown): Promise<T> {
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<T>(url: string): Promise<T> { async function deleteJson<T>(url: string): Promise<T> {
const res = await fetch(url, { method: 'DELETE' }); const res = await fetch(url, { method: 'DELETE' });
if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); 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}`), deleteJson<{ success: boolean; message: string }>(`${BASE}/schedules/${jobName}`),
toggleSchedule: (jobName: string, active: boolean) => toggleSchedule: (jobName: string, active: boolean) =>
postJson<{ success: boolean; message: string; data?: ScheduleResponse }>( patchJson<{ success: boolean; message: string; data?: ScheduleResponse }>(
`${BASE}/schedules/${jobName}/toggle`, { active }), `${BASE}/schedules/${jobName}/toggle`, { active }),
// Timeline // Timeline