diff --git a/frontend/src/hooks/api/workspace/mutations.tsx b/frontend/src/hooks/api/workspace/mutations.tsx index 3b12c9210..5ac54a089 100644 --- a/frontend/src/hooks/api/workspace/mutations.tsx +++ b/frontend/src/hooks/api/workspace/mutations.tsx @@ -2,6 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { apiRequest } from "@app/config/request"; +import { userKeys } from "../users/queries"; import { workspaceKeys } from "./queries"; import { TUpdateWorkspaceGroupRoleDTO } from "./types"; @@ -51,14 +52,25 @@ export const useUpdateGroupWorkspaceRole = () => { export const useDeleteGroupFromWorkspace = () => { const queryClient = useQueryClient(); return useMutation({ - mutationFn: async ({ groupSlug, projectSlug }: { groupSlug: string; projectSlug: string }) => { + mutationFn: async ({ + groupSlug, + projectSlug + }: { + groupSlug: string; + projectSlug: string; + username?: string; + }) => { const { data: { groupMembership } } = await apiRequest.delete(`/api/v2/workspace/${projectSlug}/groups/${groupSlug}`); return groupMembership; }, - onSuccess: (_, { projectSlug }) => { + onSuccess: (_, { projectSlug, username }) => { queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectSlug)); + + if (username) { + queryClient.invalidateQueries(userKeys.listUserGroupMemberships(username)); + } } }); };