quivr/frontend/lib/api/chat/useChatApi.ts
Mamadou DICKO 10af0c949a
feat: add notifications components (#1148)
* feat: rename ChatMessages to MessagesDialog

* feat: rename history to messages

* feat: add notifications to ChatContext

* feat: add getNotificationsFromChatHistory

* feat: add getMergedChatHistoryWithReducedNotifications

* refactor: update useActionBar

* refactor: update <ChatMessage />-n

* feat: update crawler and endpoint notifications content

* feat: display notifications

* test: update <MessageDialog /> tests

* feat: rename ChatMessage to QADisplay

* feat: rename ChatHistory to ChatMessage

* feat(upload): throw error when file missing

* feat: rename getMergedChatHistoryWithReducedNotifications to getMergedChatMessagesWithReducedNotifications

* feat: change history wording to message

* feat: move getFileIcon to lib

* refactor(NotificationDisplayer): move types to types.ts

* chore: improve ux

* feat: rename MessagesDialog to ChatDialogue
2023-09-12 17:44:15 +02:00

30 lines
952 B
TypeScript

import { useAxios } from "@/lib/hooks";
import {
addQuestion,
AddQuestionParams,
ChatUpdatableProperties,
createChat,
deleteChat,
getChatItems,
getChats,
updateChat,
} from "./chat";
// TODO: split './chat.ts' into multiple files, per function for example
// 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),
addQuestion: async (props: AddQuestionParams) =>
addQuestion(props, axiosInstance),
getChatItems: async (chatId: string) => getChatItems(chatId, axiosInstance),
updateChat: async (chatId: string, props: ChatUpdatableProperties) =>
updateChat(chatId, props, axiosInstance),
};
};