import React, { useState, useEffect } from 'react' import { Box, Typography, Paper, IconButton, Button, Dialog, DialogTitle, DialogContent, DialogActions, CircularProgress, Alert, } from '@mui/material' import { PictureAsPdf, Download, Close, ZoomIn, ZoomOut, NavigateBefore, NavigateNext, } from '@mui/icons-material' import type { Document } from '../types' interface FilePreviewProps { document: Document onClose: () => void } export const FilePreview: React.FC = ({ document, onClose }) => { const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [page, setPage] = useState(1) const [scale, setScale] = useState(1.0) const [numPages, setNumPages] = useState(0) useEffect(() => { setLoading(true) setError(null) setPage(1) setScale(1.0) // Simuler le chargement du PDF const timer = setTimeout(() => { setNumPages(3) // Simuler 3 pages setLoading(false) }, 1000) return () => clearTimeout(timer) }, [document]) const handleDownload = () => { if (document.previewUrl) { const link = window.document.createElement('a') link.href = document.previewUrl link.download = document.name link.click() } } const isPDF = document.type.includes('pdf') || document.name.toLowerCase().endsWith('.pdf') if (!isPDF) { return ( {document.name} Aperçu non disponible pour ce type de fichier ({document.type}) ) } return ( {document.name} {loading && ( Chargement du PDF... )} {error && ( {error} )} {!loading && !error && ( {/* Contrôles de navigation */} Page {page} sur {numPages} {Math.round(scale * 100)}% {/* Aperçu PDF avec viewer intégré */} {document.previewUrl ? ( {/* Utiliser un viewer PDF intégré */}