feat: add API for fetching ALL permissions
This commit is contained in:
@ -3,7 +3,7 @@ import { axios, handleApiError } from "..";
|
|||||||
|
|
||||||
export type FetchPermissionsResponse = AppPermission[];
|
export type FetchPermissionsResponse = AppPermission[];
|
||||||
|
|
||||||
export const getPermissionsApi = async (
|
export const getUserPermissionsApi = async (
|
||||||
userId: string,
|
userId: string,
|
||||||
): Promise<FetchPermissionsResponse> => {
|
): Promise<FetchPermissionsResponse> => {
|
||||||
const response = await axios.get<FetchPermissionsResponse>(
|
const response = await axios.get<FetchPermissionsResponse>(
|
||||||
@ -15,3 +15,20 @@ export const getPermissionsApi = async (
|
|||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type FetchGroupedPermissionsResponse = {
|
||||||
|
scope: string;
|
||||||
|
permissions: AppPermission[];
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export const getPermissionsApi =
|
||||||
|
async (): Promise<FetchGroupedPermissionsResponse> => {
|
||||||
|
const response = await axios.get<FetchGroupedPermissionsResponse>(
|
||||||
|
"/api/v1/admin/permissions",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status !== 200 && response.status !== 201)
|
||||||
|
throw await handleApiError(response);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user