update chat api service

This commit is contained in:
thierryverse 2025-11-15 03:28:33 +02:00
parent b35a5aa589
commit 776660f5e3
5 changed files with 137 additions and 122 deletions

View file

@ -2,6 +2,7 @@ import { atomWithMutation } from "jotai-tanstack-query";
import { toast } from "sonner";
import type { Chat } from "@/app/dashboard/[search_space_id]/chats/chats-client";
import { deleteChat } from "@/lib/apis/chats.api";
import { chatApiService } from "@/lib/apis/chats-api.service";
import { cacheKeys } from "@/lib/query-client/cache-keys";
import { queryClient } from "@/lib/query-client/client";
import { activeSearchSpaceIdAtom } from "../seach-spaces/seach-space-queries.atom";
@ -14,14 +15,7 @@ export const deleteChatMutationAtom = atomWithMutation((get) => {
mutationKey: cacheKeys.activeSearchSpace.chats(searchSpaceId ?? ""),
enabled: !!searchSpaceId && !!authToken,
mutationFn: async (chatId: number) => {
if (!authToken) {
throw new Error("No authentication token found");
}
if (!searchSpaceId) {
throw new Error("No search space id found");
}
return deleteChat(chatId, authToken);
return chatApiService.deleteChat({ id: chatId });
},
onSuccess: (_, chatId) => {