2023-07-05 14:33:26 +03:00
|
|
|
import { useAxios } from "@/lib/hooks";
|
|
|
|
|
2023-07-05 14:39:07 +03:00
|
|
|
import {
|
|
|
|
addQuestion,
|
|
|
|
AddQuestionParams,
|
2023-07-05 19:33:18 +03:00
|
|
|
ChatUpdatableProperties,
|
2023-07-05 14:39:07 +03:00
|
|
|
createChat,
|
|
|
|
deleteChat,
|
|
|
|
getChats,
|
2023-07-05 19:33:18 +03:00
|
|
|
getHistory,
|
|
|
|
updateChat,
|
2023-07-05 14:39:07 +03:00
|
|
|
} from "./chat";
|
2023-07-05 14:33:26 +03:00
|
|
|
|
2023-07-05 19:33:18 +03:00
|
|
|
// TODO: split './chat.ts' into multiple files, per function for example
|
2023-07-05 14:33:26 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
export const useChatApi = () => {
|
|
|
|
const { axiosInstance } = useAxios();
|
|
|
|
|
|
|
|
return {
|
|
|
|
createChat: async (chatName: string) => createChat(chatName, axiosInstance),
|
|
|
|
getChats: async () => getChats(axiosInstance),
|
|
|
|
deleteChat: async (chatId: string) => deleteChat(chatId, axiosInstance),
|
2023-07-05 14:39:07 +03:00
|
|
|
addQuestion: async (props: AddQuestionParams) =>
|
|
|
|
addQuestion(props, axiosInstance),
|
2023-07-05 19:33:18 +03:00
|
|
|
getHistory: async (chatId: string) => getHistory(chatId, axiosInstance),
|
|
|
|
updateChat: async (chatId: string, props: ChatUpdatableProperties) =>
|
|
|
|
updateChat(chatId, props, axiosInstance),
|
2023-07-05 14:33:26 +03:00
|
|
|
};
|
|
|
|
};
|