first pass of new UI
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
export type Role = {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
description: string | null;
|
||||
members: any[];
|
||||
};
|
||||
import { Member, MemberLight } from "@shared/types/member";
|
||||
import { Role } from "@shared/types/roles";
|
||||
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
@@ -22,6 +17,30 @@ export async function getRoles(): Promise<Role[]> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRoleDetails(id: number): Promise<Role> {
|
||||
const res = await fetch(`${addr}/roles/${id}`, {
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
return res.json() as Promise<Role>;
|
||||
} else {
|
||||
throw new Error("Could not load role");
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRoleMembers(id: number): Promise<MemberLight[]> {
|
||||
const res = await fetch(`${addr}/roles/${id}/members`, {
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
throw new Error("Could not load members");
|
||||
}
|
||||
}
|
||||
|
||||
export async function createRole(name: string, color: string, description: string | null): Promise<Role | null> {
|
||||
const res = await fetch(`${addr}/roles`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user