import { authFetch } from '../../../utils/authFetch'; export async function deleteAffiliate(id: string) { const BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001'; const url = `${BASE_URL}/api/admin/affiliates/${id}`; const res = await authFetch(url, { method: 'DELETE', headers: { Accept: 'application/json', }, }); let body: any = null; try { body = await res.json(); } catch { body = null; } const ok = res.ok; const message = body?.message || (res.status === 404 ? 'Affiliate not found.' : res.status === 403 ? 'Forbidden.' : res.status === 500 ? 'Server error.' : !ok ? `Request failed (${res.status}).` : 'Affiliate deleted successfully.'); return { ok, status: res.status, body, message }; }