mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-14 22:52:15 +02:00
- Introduced a comprehensive specification for renaming `searchSpace` to `workspace` in `surfsense_web` and `surfsense_desktop`, ensuring all TypeScript identifiers, React props, and local data structures are updated. - Implemented migration shims for persisted local state to prevent data loss during the transition. - Updated observability metrics and IPC channels to reflect the new naming convention. - Removed legacy `active-search-space` module and replaced it with `active-workspace` to maintain consistency. - Ensured no behavioral changes or data loss for users during the renaming process.
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import { atomWithMutation } from "jotai-tanstack-query";
|
|
import { toast } from "sonner";
|
|
import type {
|
|
AcceptInviteRequest,
|
|
CreateInviteRequest,
|
|
DeleteInviteRequest,
|
|
UpdateInviteRequest,
|
|
} from "@/contracts/types/invites.types";
|
|
import { invitesApiService } from "@/lib/apis/invites-api.service";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
import { queryClient } from "@/lib/query-client/client";
|
|
|
|
/**
|
|
* Mutation atom for creating an invite
|
|
*/
|
|
export const createInviteMutationAtom = atomWithMutation(() => ({
|
|
meta: { suppressGlobalErrorToast: true },
|
|
mutationFn: async (request: CreateInviteRequest) => {
|
|
return invitesApiService.createInvite(request);
|
|
},
|
|
onSuccess: (_, variables) => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.invites.all(variables.workspace_id.toString()),
|
|
});
|
|
toast.success("Invite created successfully");
|
|
},
|
|
onError: (error: Error) => {
|
|
console.error("Error creating invite:", error);
|
|
toast.error("Failed to create invite");
|
|
},
|
|
}));
|
|
|
|
/**
|
|
* Mutation atom for updating an invite
|
|
*/
|
|
export const updateInviteMutationAtom = atomWithMutation(() => ({
|
|
meta: { suppressGlobalErrorToast: true },
|
|
mutationFn: async (request: UpdateInviteRequest) => {
|
|
return invitesApiService.updateInvite(request);
|
|
},
|
|
onSuccess: (_, variables) => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.invites.all(variables.workspace_id.toString()),
|
|
});
|
|
toast.success("Invite updated successfully");
|
|
},
|
|
onError: (error: Error) => {
|
|
console.error("Error updating invite:", error);
|
|
toast.error("Failed to update invite");
|
|
},
|
|
}));
|
|
|
|
/**
|
|
* Mutation atom for deleting an invite
|
|
*/
|
|
export const deleteInviteMutationAtom = atomWithMutation(() => ({
|
|
meta: { suppressGlobalErrorToast: true },
|
|
mutationFn: async (request: DeleteInviteRequest) => {
|
|
return invitesApiService.deleteInvite(request);
|
|
},
|
|
onSuccess: (_, variables) => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.invites.all(variables.workspace_id.toString()),
|
|
});
|
|
toast.success("Invite deleted successfully");
|
|
},
|
|
onError: (error: Error) => {
|
|
console.error("Error deleting invite:", error);
|
|
toast.error("Failed to delete invite");
|
|
},
|
|
}));
|
|
|
|
/**
|
|
* Mutation atom for accepting an invite
|
|
*/
|
|
export const acceptInviteMutationAtom = atomWithMutation(() => ({
|
|
meta: { suppressGlobalErrorToast: true },
|
|
mutationFn: async (request: AcceptInviteRequest) => {
|
|
return invitesApiService.acceptInvite(request);
|
|
},
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: cacheKeys.workspaces.all });
|
|
toast.success("Invite accepted successfully");
|
|
},
|
|
onError: (error: Error) => {
|
|
console.error("Error accepting invite:", error);
|
|
toast.error("Failed to accept invite");
|
|
},
|
|
}));
|