feat: get permissions call
This commit is contained in:
16
web/src/api/admin/permissions.ts
Normal file
16
web/src/api/admin/permissions.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import type { AppPermission } from "@/types";
|
||||||
|
import { axios, handleApiError } from "..";
|
||||||
|
|
||||||
|
export type FetchPermissionsResponse = AppPermission[];
|
||||||
|
|
||||||
|
export const getPermissionsApi =
|
||||||
|
async (): Promise<FetchPermissionsResponse> => {
|
||||||
|
const response = await axios.get<FetchPermissionsResponse>(
|
||||||
|
"/api/v1/admin/permissions",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status !== 200 && response.status !== 201)
|
||||||
|
throw await handleApiError(response);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
};
|
@ -1,3 +1,4 @@
|
|||||||
|
import { getPermissionsApi } from "@/api/admin/permissions";
|
||||||
import Breadcrumbs from "@/components/ui/breadcrumbs";
|
import Breadcrumbs from "@/components/ui/breadcrumbs";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Avatar from "@/feature/Avatar";
|
import Avatar from "@/feature/Avatar";
|
||||||
@ -15,6 +16,12 @@ const AdminUsersPage: FC = () => {
|
|||||||
fetchUsers();
|
fetchUsers();
|
||||||
}, [fetchUsers]);
|
}, [fetchUsers]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getPermissionsApi().then((res) => {
|
||||||
|
console.log("permissions response:", res);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex flex-col items-stretch w-full">
|
<div className="relative flex flex-col items-stretch w-full">
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
|
@ -78,3 +78,10 @@ export interface DeviceInfo {
|
|||||||
browser: string;
|
browser: string;
|
||||||
browser_version: string;
|
browser_version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AppPermission {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
scope: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user