import { useTheme } from "@emotion/react";
import { Box } from "@mui/material";
import { useEffect } from "react";
import ChunkComponent from "../chunkComponent";

export default function PreviewChunks({ chunks, onSelectedChunk }) {
  const theme = useTheme();

  useEffect(() => {}, [chunks]);
  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: "60%",
        }}
      >
        {chunks.map((document, index) => (
          <ChunkComponent
            key={index}
            documentName={`Chunk ${document.id}`}
            documentId={`Document_${document.id}`}
            documentNumber={index}
            onSelectedChunk={onSelectedChunk}
          ></ChunkComponent>
        ))}
      </Box>
    </>
  );
}
