feat: add deleteInviteMutationAtom

This commit is contained in:
CREDO23 2025-12-16 16:14:36 +00:00
parent 9c22ae2da5
commit 5e0bc3823c

View file

@ -47,3 +47,22 @@ export const updateInviteMutationAtom = atomWithMutation(() => ({
toast.error("Failed to update invite");
},
}));
/**
* Mutation atom for deleting an invite
*/
export const deleteInviteMutationAtom = atomWithMutation(() => ({
mutationFn: async (request: DeleteInviteRequest) => {
return invitesApiService.deleteInvite(request);
},
onSuccess: (_, variables) => {
queryClient.invalidateQueries({
queryKey: cacheKeys.invites.all(variables.search_space_id.toString()),
});
toast.success("Invite deleted successfully");
},
onError: (error: Error) => {
console.error("Error deleting invite:", error);
toast.error("Failed to delete invite");
},
}));