// src/backend/utils/onboardingDraftApi.js import authFetch from '../../utils/authFetch.js'; const DRAFT_URL = '/api/premium/onboarding/draft'; export async function loadDraft() { const res = await authFetch(DRAFT_URL); if (res.status === 404) return null; if (!res.ok) throw new Error(`loadDraft failed: ${res.status}`); return res.json(); // -> { id, step, data } | null } export async function saveDraft({ id, step = 0, data = {} }) { const res = await authFetch(DRAFT_URL, { method: 'POST', body: JSON.stringify({ id, step, data }) }); if (!res.ok) throw new Error(`saveDraft failed: ${res.status}`); return res.json(); // -> { id, step } } export async function clearDraft() { const res = await authFetch(DRAFT_URL, { method: 'DELETE' }); if (!res.ok) throw new Error(`clearDraft failed: ${res.status}`); return res.json(); // -> { ok: true } }