export type LOARequest = { member_id: number; filed_date: string; // ISO 8601 string start_date: string; // ISO 8601 string end_date: string; // ISO 8601 string reason?: string; }; // @ts-ignore const addr = import.meta.env.VITE_APIHOST; export async function submitLOA(request: LOARequest): Promise<{ id?: number; error?: string }> { const res = await fetch(`${addr}/loa`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(request), }); if (res.ok) { return res.json(); } else { return { error: "Failed to submit LOA" }; } } export async function getMyLOA(): Promise { const res = await fetch(`${addr}/loa/me`, { method: "GET", headers: { "Content-Type": "application/json", }, }); if (res.ok) { const out = res.json(); if (!out) { return null; } return out; } else { return null; } }