Merge remote-tracking branch 'Origin/main' into promotions
This commit is contained in:
18
ui/src/api/docs.ts
Normal file
18
ui/src/api/docs.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function getWelcomeMessage(): Promise<string> {
|
||||
const res = await fetch(`${addr}/docs/welcome`, {
|
||||
method: "GET",
|
||||
credentials: 'include',
|
||||
});
|
||||
if (res.ok) {
|
||||
const out = res.json();
|
||||
if (!out) {
|
||||
return null;
|
||||
}
|
||||
return out;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -31,9 +31,9 @@ export async function adminSubmitLOA(request: LOARequest): Promise<{ id?: number
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
return
|
||||
} else {
|
||||
return { error: "Failed to submit LOA" };
|
||||
throw new Error("Failed to submit LOA");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +85,18 @@ export async function getAllLOAs(page?: number, pageSize?: number): Promise<Page
|
||||
});
|
||||
}
|
||||
|
||||
export function getMyLOAs(): Promise<LOARequest[]> {
|
||||
return fetch(`${addr}/loa/history`, {
|
||||
export function getMyLOAs(page?: number, pageSize?: number): Promise<PagedData<LOARequest>> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (page !== undefined) {
|
||||
params.set("page", page.toString());
|
||||
}
|
||||
|
||||
if (pageSize !== undefined) {
|
||||
params.set("pageSize", pageSize.toString());
|
||||
}
|
||||
|
||||
return fetch(`${addr}/loa/history?${params}`, {
|
||||
method: "GET",
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
|
||||
@@ -10,7 +10,9 @@ export type Role = {
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function getRoles(): Promise<Role[]> {
|
||||
const res = await fetch(`${addr}/roles`)
|
||||
const res = await fetch(`${addr}/roles`, {
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
return res.json() as Promise<Role[]>;
|
||||
@@ -26,11 +28,12 @@ export async function createRole(name: string, color: string, description: strin
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
color,
|
||||
description
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
@@ -47,6 +50,7 @@ export async function addMemberToRole(member_id: number, role_id: number): Promi
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
member_id,
|
||||
role_id
|
||||
@@ -64,6 +68,7 @@ export async function addMemberToRole(member_id: number, role_id: number): Promi
|
||||
export async function removeMemberFromRole(member_id: number, role_id: number): Promise<boolean> {
|
||||
const res = await fetch(`${addr}/memberRoles`, {
|
||||
method: "DELETE",
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
@@ -83,7 +88,8 @@ export async function removeMemberFromRole(member_id: number, role_id: number):
|
||||
|
||||
export async function deleteRole(role_id: number): Promise<boolean> {
|
||||
const res = await fetch(`${addr}/roles/${role_id}`, {
|
||||
method: "DELETE"
|
||||
method: "DELETE",
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user