implemented LOA cancelling and extensioning

This commit is contained in:
2025-12-11 19:08:24 -05:00
parent a3216ba5ab
commit bcde81093d
7 changed files with 219 additions and 82 deletions

View File

@@ -90,7 +90,6 @@ export async function getLoaTypes(): Promise<LOAType[]> {
};
export async function getLoaPolicy(): Promise<string> {
//@ts-ignore
const res = await fetch(`${addr}/loa/policy`, {
method: "GET",
credentials: 'include',
@@ -106,3 +105,34 @@ export async function getLoaPolicy(): Promise<string> {
return null;
}
}
export async function cancelLOA(id: number, admin: boolean = false) {
let route = admin ? 'adminCancel' : 'cancel';
const res = await fetch(`${addr}/loa/${route}/${id}`, {
method: "POST",
credentials: 'include',
});
if (res.ok) {
return
} else {
throw new Error("Could not cancel LOA");
}
}
export async function extendLOA(id: number, to: Date) {
const res = await fetch(`${addr}/loa/extend/${id}`, {
method: "POST",
credentials: 'include',
body: JSON.stringify({ to }),
headers: {
"Content-Type": "application/json",
}
});
if (res.ok) {
return
} else {
throw new Error("Could not extend LOA");
}
}