feat: role list section completed with delete

This commit is contained in:
=
2024-10-25 00:59:39 +05:30
parent 558a809b4c
commit 3e8f1d8de7
30 changed files with 444 additions and 53 deletions
+2 -1
View File
@@ -36,6 +36,7 @@ export {
useUpdateIdentityWorkspaceRole,
useUpdateUserWorkspaceRole,
useUpdateWsEnvironment,
useUpgradeProject
useUpgradeProject,
useGetWorkspaceUserDetails
} from "./queries";
export { workspaceKeys } from "./query-keys";
@@ -365,6 +365,21 @@ export const useGetWorkspaceUsers = (workspaceId: string, includeGroupMembers?:
});
};
export const useGetWorkspaceUserDetails = (workspaceId: string, membershipId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId),
queryFn: async () => {
const {
data: { membership }
} = await apiRequest.get<{ membership: TWorkspaceUser }>(
`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`
);
return membership;
},
enabled: Boolean(workspaceId) && Boolean(membershipId)
});
};
export const useDeleteUserFromWorkspace = () => {
const queryClient = useQueryClient();
@@ -15,6 +15,8 @@ export const workspaceKeys = {
getWorkspaceAuditLogs: (workspaceId: string) =>
[{ workspaceId }, "workspace-audit-logs"] as const,
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }, "workspace-users"] as const,
getWorkspaceUserDetails: (workspaceId: string, membershipId: string) =>
[{ workspaceId, membershipId }, "workspace-user-details"] as const,
getWorkspaceIdentityMemberships: (workspaceId: string) =>
[{ workspaceId }, "workspace-identity-memberships"] as const,
// allows invalidation using above key without knowing params