mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
feat: add createSearchSpaceMutationAtom
This commit is contained in:
parent
3fafb18089
commit
6bac012474
1 changed files with 24 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { atomWithMutation } from "jotai-tanstack-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import type {
|
||||||
|
CreateSearchSpaceRequest,
|
||||||
|
} from "@/contracts/types/search-space.types";
|
||||||
|
import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
||||||
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||||
|
import { queryClient } from "@/lib/query-client/client";
|
||||||
|
|
||||||
|
export const createSearchSpaceMutationAtom = atomWithMutation(() => {
|
||||||
|
return {
|
||||||
|
mutationKey: ["create-search-space"],
|
||||||
|
mutationFn: async (request: CreateSearchSpaceRequest) => {
|
||||||
|
return searchSpacesApiService.createSearchSpace(request);
|
||||||
|
},
|
||||||
|
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success("Search space created successfully");
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: cacheKeys.searchSpaces.all,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue