improve naming

This commit is contained in:
thierryverse 2025-11-12 13:27:15 +02:00
parent 207a284e9d
commit bd4e5d627d
14 changed files with 90 additions and 54 deletions

View file

@ -54,3 +54,27 @@ export const fetchChatsBySearchSpace = async (
return null;
}
};
export const deleteChat = async (chatId: number, authToken: string) => {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/chats/${chatId}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
if (!response.ok) {
throw new Error(`Failed to delete chat: ${response.statusText}`);
}
return true;
} catch (err) {
console.error("Error deleting chat:", err);
return false;
}
};

View file

@ -1,4 +1,7 @@
export const cacheKeys = {
activeChat: (chatId: string) => ["activeChat", chatId],
activeSearchSpaceChats: (searchSpaceId: string) => ["activeSearchSpaceChats", searchSpaceId],
activeSearchSpace: {
chats : (searchSpaceId: string) => ["active-search-space", "chats", searchSpaceId] as const,
activeChat : (chatId: string) => ["active-search-space", "active-chat", chatId] as const,
deleteChat : ( searchSpaceId: string, chatId: string) => ["active-search-space", "chats", searchSpaceId, "delete", chatId] as const,
},
};