mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-25 04:12:44 +03:00
d2b4ef4aff
* ✨ get all knowledge utils * ✨ add remove knowledge and update router * ✨ new knowledge provider * 🚨 remove eslint -disable * ✨ new useKnowledgeApi * ✨ set up KnowledgeItem * ✨ add KnowledgeTable component in knowledge tab * 🔥 remove DocumentData replaced by KnowledgeItem * 🐛 fix weird characters instead of '/' * 💄 truncate knowledge name * ✨ add DownloadUploadedKnowledge component * ⚰️ unused code * 🏷️ introduce UploadedKnowledge and CrawledKnowledge types * 💄 remove thread * 💄 bin for delete knowledge * 🌐 update wording for knowledge tab * 🔇 remove logs and comments
35 lines
739 B
TypeScript
35 lines
739 B
TypeScript
"use client";
|
|
|
|
import { createContext, useState } from "react";
|
|
|
|
import { ChatEntity } from "@/app/chat/[chatId]/types";
|
|
|
|
type ChatsContextType = {
|
|
allChats: ChatEntity[];
|
|
//set setAllChats is from the useState hook so it can take a function as params
|
|
setAllChats: React.Dispatch<React.SetStateAction<ChatEntity[]>>;
|
|
};
|
|
|
|
export const ChatsContext = createContext<ChatsContextType | undefined>(
|
|
undefined
|
|
);
|
|
|
|
export const ChatsProvider = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}): JSX.Element => {
|
|
const [allChats, setAllChats] = useState<ChatEntity[]>([]);
|
|
|
|
return (
|
|
<ChatsContext.Provider
|
|
value={{
|
|
allChats,
|
|
setAllChats,
|
|
}}
|
|
>
|
|
{children}
|
|
</ChatsContext.Provider>
|
|
);
|
|
};
|