quivr/frontend/lib/context/KnowledgeProvider/knowledge-provider.tsx
Zineb El Bachiri d2b4ef4aff
feat: knowledge tab list (#1222)
*  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
2023-09-22 16:06:04 +02:00

34 lines
697 B
TypeScript

"use client";
import { createContext, useState } from "react";
import { Knowledge } from "@/lib/types/Knowledge";
type KnowledgeContextType = {
allKnowledge: Knowledge[];
setAllKnowledge: React.Dispatch<React.SetStateAction<Knowledge[]>>;
};
export const KnowledgeContext = createContext<KnowledgeContextType | undefined>(
undefined
);
export const KnowledgeProvider = ({
children,
}: {
children: React.ReactNode;
}): JSX.Element => {
const [allKnowledge, setAllKnowledge] = useState<Knowledge[]>([]);
return (
<KnowledgeContext.Provider
value={{
allKnowledge,
setAllKnowledge,
}}
>
{children}
</KnowledgeContext.Provider>
);
};