feat: roles API + type def
This commit is contained in:
20
web/src/api/admin/roles.ts
Normal file
20
web/src/api/admin/roles.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { AppPermission, AppRole } from "@/types";
|
||||
import { axios, handleApiError } from "..";
|
||||
|
||||
export type FetchGroupedRolesResponse = {
|
||||
scope: string;
|
||||
roles: (AppRole & {
|
||||
permissions: AppPermission[];
|
||||
})[];
|
||||
}[];
|
||||
|
||||
export const getRolesApi = async (): Promise<FetchGroupedRolesResponse> => {
|
||||
const response = await axios.get<FetchGroupedRolesResponse>(
|
||||
"/api/v1/admin/roles",
|
||||
);
|
||||
|
||||
if (response.status !== 200 && response.status !== 201)
|
||||
throw await handleApiError(response);
|
||||
|
||||
return response.data;
|
||||
};
|
@ -85,3 +85,10 @@ export interface AppPermission {
|
||||
scope: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface AppRole {
|
||||
id: string;
|
||||
name: string;
|
||||
scope: string;
|
||||
description: string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user