import React from "react"; import { Dialog, DialogTitle, DialogContent, Box, Typography, CircularProgress, IconButton, Tooltip, } from "@mui/material"; import DownloadIcon from "@mui/icons-material/Download"; import CloseIcon from "@mui/icons-material/Close"; /** * Composant pour afficher un document dans une boîte de dialogue * @param {Object} props - Propriétés du composant * @returns {JSX.Element} - Dialogue pour visualiser un document */ const DocumentViewerDialog = ({ open, onClose, document, content, isLoading, isDownloading, handleDownload, }) => { // Déterminer le type de document const getDocumentType = () => { if (!document) return ""; if (document.id === "the-bitter-lesson") return "HTML"; if (document.id === "hurricane-faq") return "Markdown"; return "Text"; }; return ( {document && ( {document.name} )} {document && getDocumentType()} {document && ( handleDownload(document)} disabled={isDownloading} aria-label="download" sx={{ color: "text.secondary", opacity: 0.4, "&:hover": { opacity: 0.8, }, }} > {isDownloading ? ( ) : ( )} )} {isLoading ? ( ) : ( {content} )} ); }; export default DocumentViewerDialog;