mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 16:11:45 +03:00
32 lines
703 B
TypeScript
32 lines
703 B
TypeScript
|
import { AxiosInstance } from "axios";
|
||
|
|
||
|
import { ChatEntity } from "@/app/chat/[chatId]/types";
|
||
|
|
||
|
export const createChat = async (
|
||
|
name: string,
|
||
|
axiosInstance: AxiosInstance
|
||
|
): Promise<ChatEntity> => {
|
||
|
const createdChat = (
|
||
|
await axiosInstance.post<ChatEntity>("/chat", { name: name })
|
||
|
).data;
|
||
|
|
||
|
return createdChat;
|
||
|
};
|
||
|
|
||
|
export const getChats = async (
|
||
|
axiosInstance: AxiosInstance
|
||
|
): Promise<ChatEntity[]> => {
|
||
|
const response = await axiosInstance.get<{
|
||
|
chats: ChatEntity[];
|
||
|
}>(`/chat`);
|
||
|
|
||
|
return response.data.chats;
|
||
|
};
|
||
|
|
||
|
export const deleteChat = async (
|
||
|
chatId: string,
|
||
|
axiosInstance: AxiosInstance
|
||
|
): Promise<void> => {
|
||
|
await axiosInstance.delete(`/chat/${chatId}`);
|
||
|
};
|