mirror of
https://github.com/docmost/docmost.git
synced 2025-11-15 07:31:16 +10:00
feat: delete workspace member (#987)
* add delete user endpoint (server) * delete user (UI) * prevent token generation * more checks
This commit is contained in:
@ -16,6 +16,7 @@ import {
|
||||
getWorkspace,
|
||||
getWorkspacePublicData,
|
||||
getAppVersion,
|
||||
deleteWorkspaceMember,
|
||||
} from "@/features/workspace/services/workspace-service";
|
||||
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
@ -56,6 +57,30 @@ export function useWorkspaceMembersQuery(
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteWorkspaceMemberMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<
|
||||
void,
|
||||
Error,
|
||||
{
|
||||
userId: string;
|
||||
}
|
||||
>({
|
||||
mutationFn: (data) => deleteWorkspaceMember(data),
|
||||
onSuccess: (data, variables) => {
|
||||
notifications.show({ message: "Member deleted successfully" });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["workspaceMembers"],
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
const errorMessage = error["response"]?.data?.message;
|
||||
notifications.show({ message: errorMessage, color: "red" });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useChangeMemberRoleMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user