Spaces:
Sleeping
Sleeping
| import baseUrl from "@/services/api/api.config"; | |
| import { useTheme } from "@emotion/react"; | |
| import { Box } from "@mui/material"; | |
| import { useEffect } from "react"; | |
| import DocumentComponent from "../documentComponent"; | |
| export default function PreviewDocuments({ documents, fetchChunks }) { | |
| const theme = useTheme(); | |
| const deleteDcoument = async (documentName) => { | |
| const url = `${baseUrl}/document/delete_document/${encodeURIComponent( | |
| documentName | |
| )}`; | |
| const result = await fetch(url, { | |
| method: "DELETE", | |
| headers: { "Content-Type": "application/json" }, | |
| }); | |
| await fetchChunks(); | |
| }; | |
| useEffect(() => {}, [documents]); | |
| return ( | |
| <> | |
| <Box | |
| display="flex" | |
| flexDirection="column" | |
| flexGrow={1} | |
| padding={2} | |
| mb={2} | |
| style={{ | |
| border: "2px solid black", | |
| overflow: "hidden", | |
| overflowY: "scroll", | |
| borderRadius: "8px", | |
| border: "1px solid #ccc", | |
| backgroundColor: theme.palette.background.default, | |
| height: "40%", | |
| }} | |
| > | |
| {documents.map((document, index) => ( | |
| <DocumentComponent | |
| key={index} | |
| documentName={document.filename} | |
| documentId={`Document_${document.id}`} | |
| documentNumber={document.id} | |
| deleteDocument={deleteDcoument} | |
| ></DocumentComponent> | |
| ))} | |
| </Box> | |
| </> | |
| ); | |
| } | |