feat: roles API + type def

This commit is contained in:
2025-06-25 11:56:06 +02:00
parent 5d49a661ed
commit d80caac81b
2 changed files with 27 additions and 0 deletions

View 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;
};

View File

@ -85,3 +85,10 @@ export interface AppPermission {
scope: string;
description: string;
}
export interface AppRole {
id: string;
name: string;
scope: string;
description: string;
}