SurfSense/surfsense_web/atoms/public-chat-snapshots/public-chat-snapshots-mutation.atoms.ts

18 lines
687 B
TypeScript
Raw Normal View History

import { atomWithMutation } from "jotai-tanstack-query";
import { toast } from "sonner";
import type { PublicChatSnapshotDeleteRequest } from "@/contracts/types/chat-threads.types";
import { chatThreadsApiService } from "@/lib/apis/chat-threads-api.service";
export const deletePublicChatSnapshotMutationAtom = atomWithMutation(() => ({
mutationFn: async (request: PublicChatSnapshotDeleteRequest) => {
return chatThreadsApiService.deletePublicChatSnapshot(request);
},
onSuccess: () => {
toast.success("Public link deleted");
},
onError: (error: Error) => {
console.error("Failed to delete public chat link:", error);
toast.error("Failed to delete public link");
},
}));