permission menu
This commit is contained in:
@@ -52,3 +52,10 @@ export const useDeleteAdmin = () => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetAdminMe = () => {
|
||||
return useQuery({
|
||||
queryKey: ["adminMe"],
|
||||
queryFn: api.getAdminMe,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
CreateAdminType,
|
||||
RolesResponseType,
|
||||
AdminDetailResponseType,
|
||||
AdminMeResponseType,
|
||||
} from "../types/Types";
|
||||
|
||||
export const getAdmins = async (page: number, limit: number = 10) => {
|
||||
@@ -46,3 +47,8 @@ export const deleteAdmin = async (adminId: string) => {
|
||||
const { data } = await axios.delete(`/admin/admins/${adminId}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getAdminMe = async () => {
|
||||
const { data } = await axios.get<AdminMeResponseType>("/admin/admins/me");
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -48,3 +48,9 @@ export type RoleItemType = {
|
||||
|
||||
export type RolesResponseType = BaseResponse<RoleItemType[]>;
|
||||
export type AdminDetailResponseType = BaseResponse<AdminItemType>;
|
||||
|
||||
/** Admin "me" response: admin with full role including permissions */
|
||||
export type AdminMeDataType = Omit<AdminItemType, "role"> & {
|
||||
role: RoleItemType;
|
||||
};
|
||||
export type AdminMeResponseType = BaseResponse<AdminMeDataType>;
|
||||
|
||||
Reference in New Issue
Block a user