space updates

* space UI
* space management
* space permissions
* other fixes
This commit is contained in:
Philipinho
2024-04-12 19:38:58 +01:00
parent b02cfd02f0
commit 90ae750d48
54 changed files with 1966 additions and 365 deletions

View File

@ -1,6 +1,10 @@
import { useQuery } from "@tanstack/react-query";
import { getWorkspaceMembers } from "@/features/workspace/services/workspace-service";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
changeMemberRole,
getWorkspaceMembers,
} from "@/features/workspace/services/workspace-service";
import { QueryParams } from "@/lib/types.ts";
import { notifications } from "@mantine/notifications";
export function useWorkspaceMembersQuery(params?: QueryParams) {
return useQuery({
@ -8,3 +12,21 @@ export function useWorkspaceMembersQuery(params?: QueryParams) {
queryFn: () => getWorkspaceMembers(params),
});
}
export function useChangeMemberRoleMutation() {
const queryClient = useQueryClient();
return useMutation<any, Error, any>({
mutationFn: (data) => changeMemberRole(data),
onSuccess: (data, variables) => {
notifications.show({ message: "Member role updated successfully" });
queryClient.refetchQueries({
queryKey: ["workspaceMembers", variables.spaceId],
});
},
onError: (error) => {
const errorMessage = error["response"]?.data?.message;
notifications.show({ message: errorMessage, color: "red" });
},
});
}