From 341c082519aec791f40839d535e3dd2afb935d58 Mon Sep 17 00:00:00 2001 From: David Mang Date: Sun, 1 Sep 2024 15:27:32 +0200 Subject: [PATCH] Add comments to text pipeline --- client/src/api/chat.api.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/api/chat.api.ts b/client/src/api/chat.api.ts index ee8d2bf..8a5567e 100644 --- a/client/src/api/chat.api.ts +++ b/client/src/api/chat.api.ts @@ -1,7 +1,7 @@ import { ChatBody } from "../types/chatbot/chatbot.types"; import api from "./interceptor.api"; -// Fetch all chats for a user +// Fetch all chats for an user // @limit: Number of loaded chats. Default number is 5. export const fetchChats = async (limit: number) => { try { @@ -15,7 +15,7 @@ export const fetchChats = async (limit: number) => { } }; -// Fetch the count of all chats for a user +// Fetch the count of all chats for an user export const fetchChatsCount = async () => { try { const response = await api.get(`/api/v1/chats/count/`); @@ -26,6 +26,7 @@ export const fetchChatsCount = async () => { } }; +// Fetch chat by chat ID for an user export const fetchChatById = async (chatId: number) => { try { const response = await api.get(`/api/v1/chats/${chatId}/`); @@ -35,6 +36,8 @@ export const fetchChatById = async (chatId: number) => { } }; +// Fetch chats assigned to a page for a user +// @pageId: Id of a existing page export const fetchChatByPageId = async (pageId: number) => { try { const response = await api.get(`/api/v1/chats/page/${pageId}/`); @@ -45,6 +48,8 @@ export const fetchChatByPageId = async (pageId: number) => { } }; +// Create new chat +// @chat: title: string, page: string, labels: string[] export const createChat = async (chat: ChatBody) => { try { const response = await api.post("/api/v1/chats/", chat); @@ -55,6 +60,9 @@ export const createChat = async (chat: ChatBody) => { } }; +// Change existing chat of user +// @chat: title: string, page: string, labels: string[] +// @id: id of chat which should be changed export const changeChat = async (id: number, chat: ChatBody) => { try { const response = await api.put(`/api/v1/chats/${id}/`, chat); @@ -65,6 +73,8 @@ export const changeChat = async (id: number, chat: ChatBody) => { } }; +// Delete existing chat of user +// @id: id of chat to delete export const deleteChat = async (id: number) => { try { const response = await api.delete(`/api/v1/chats/${id}/`);