mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
feat: add leaveSearchSpaceMutationAtom
This commit is contained in:
parent
5f541cf206
commit
b20587df60
1 changed files with 19 additions and 0 deletions
|
|
@ -5,6 +5,8 @@ import type {
|
|||
UpdateMembershipResponse,
|
||||
DeleteMembershipRequest,
|
||||
DeleteMembershipResponse,
|
||||
LeaveSearchSpaceRequest,
|
||||
LeaveSearchSpaceResponse,
|
||||
} from "@/contracts/types/members.types";
|
||||
import { membersApiService } from "@/lib/apis/members-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
|
@ -43,3 +45,20 @@ export const deleteMemberMutationAtom = atomWithMutation(() => {
|
|||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const leaveSearchSpaceMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
mutationFn: async (request: LeaveSearchSpaceRequest) => {
|
||||
return membersApiService.leaveSearchSpace(request);
|
||||
},
|
||||
onSuccess: (_: LeaveSearchSpaceResponse, request: LeaveSearchSpaceRequest) => {
|
||||
toast.success("Successfully left the search space");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: cacheKeys.members.all(request.search_space_id.toString()),
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Failed to leave search space");
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue