implemented LOA cancelling and extensioning
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user