added support for posting an LOA

This commit is contained in:
2025-09-15 21:02:32 -04:00
parent 303b72a160
commit c347949920
4 changed files with 135 additions and 8 deletions

45
ui/src/api/loa.ts Normal file
View File

@@ -0,0 +1,45 @@
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;
};
const addr = "localhost:3000";
export async function submitLOA(request: LOARequest): Promise<{ id?: number; error?: string }> {
const res = await fetch(`http://${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<LOARequest | null> {
const res = await fetch(`http://${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;
}
}