Did more stuff than I even wanna write. Notably:
- Auth/account management - Navigation system - Admin views for LOA stuff
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
export type LOARequest = {
|
||||
id: number;
|
||||
name?: string;
|
||||
member_id: number;
|
||||
filed_date: string; // ISO 8601 string
|
||||
start_date: string; // ISO 8601 string
|
||||
@@ -43,3 +45,18 @@ export async function getMyLOA(): Promise<LOARequest | null> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllLOAs(): Promise<LOARequest[]> {
|
||||
return fetch(`${addr}/loa/all`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}).then((res) => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
34
ui/src/api/status.ts
Normal file
34
ui/src/api/status.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export type Status = {
|
||||
id: number;
|
||||
name: string;
|
||||
created_at: string; // datetime as ISO string
|
||||
updated_at: string; // datetime as ISO string
|
||||
deleted?: boolean; // tinyint, optional if nullable
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function getAllStatuses(): Promise<Status[]> {
|
||||
const res = await fetch(`${addr}/status`)
|
||||
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
} else {
|
||||
console.error("Something went wrong getting statuses")
|
||||
}
|
||||
}
|
||||
|
||||
export async function assignStatus(userId: number, statusId: number, rankId: number): Promise<void> {
|
||||
const res = await fetch(`${addr}/memberStatus`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ userId, statusId, rankId })
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
console.error("Something went wrong assigning the status")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user