2023-07-05 14:33:26 +03:00
|
|
|
import { useAxios } from "@/lib/hooks";
|
|
|
|
|
2023-10-12 10:39:56 +03:00
|
|
|
import {
|
|
|
|
addQuestionAndAnswer,
|
|
|
|
QuestionAndAnwser,
|
|
|
|
} from "./addQuestionAndAnswer";
|
2023-07-05 14:39:07 +03:00
|
|
|
import {
|
|
|
|
addQuestion,
|
|
|
|
AddQuestionParams,
|
2024-03-21 10:11:06 +03:00
|
|
|
ChatMessageUpdatableProperties,
|
2023-07-05 19:33:18 +03:00
|
|
|
ChatUpdatableProperties,
|
2023-07-05 14:39:07 +03:00
|
|
|
createChat,
|
|
|
|
deleteChat,
|
2023-09-12 18:44:15 +03:00
|
|
|
getChatItems,
|
2023-07-05 14:39:07 +03:00
|
|
|
getChats,
|
2023-07-05 19:33:18 +03:00
|
|
|
updateChat,
|
2024-03-21 10:11:06 +03:00
|
|
|
updateChatMessage,
|
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-09-12 18:44:15 +03:00
|
|
|
getChatItems: async (chatId: string) => getChatItems(chatId, axiosInstance),
|
2023-07-05 19:33:18 +03:00
|
|
|
updateChat: async (chatId: string, props: ChatUpdatableProperties) =>
|
|
|
|
updateChat(chatId, props, axiosInstance),
|
2023-10-12 10:39:56 +03:00
|
|
|
addQuestionAndAnswer: async (
|
|
|
|
chatId: string,
|
|
|
|
questionAndAnswer: QuestionAndAnwser
|
|
|
|
) => addQuestionAndAnswer(chatId, questionAndAnswer, axiosInstance),
|
2024-03-21 10:11:06 +03:00
|
|
|
updateChatMessage: async (
|
|
|
|
chatId: string,
|
|
|
|
messageId: string,
|
|
|
|
props: ChatMessageUpdatableProperties
|
|
|
|
) => updateChatMessage(chatId, messageId, props, axiosInstance),
|
2023-07-05 14:33:26 +03:00
|
|
|
};
|
|
|
|
};
|