import { FiFile, FiImage, FiMusic, FiFileText, FiDownload, FiX } from 'react-icons/fi'; export interface FileMetadata { type: 'audio' | 'image' | 'document' | 'spreadsheet' | 'other'; mimeType: string; size: number; originalName: string; url: string; thumbnailUrl?: string; } export interface FilePreviewProps { file: FileMetadata; onRemove?: () => void; showRemove?: boolean; compact?: boolean; } export function FilePreview({ file, onRemove, showRemove = false, compact = false }: FilePreviewProps) { const formatFileSize = (bytes: number): string => { if (bytes < 1024) return `${bytes} B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; }; const getFileIcon = () => { switch (file.type) { case 'audio': return ; case 'image': return ; case 'document': return ; case 'spreadsheet': return ; default: return ; } }; const handleDownload = () => { const link = document.createElement('a'); link.href = file.url; link.download = file.originalName; document.body.appendChild(link); link.click(); document.body.removeChild(link); }; if (compact) { // Compact view with thumbnail for images if (file.type === 'image') { return (
{file.originalName} window.open(file.url, '_blank')} /> {showRemove && onRemove && ( )}
); } return (
{getFileIcon()} {file.originalName} {showRemove && onRemove && ( )}
); } return (
{file.type === 'image' ? (
{file.originalName} window.open(file.url, '_blank')} /> {showRemove && onRemove && ( )}
) : file.type === 'audio' ? (
{getFileIcon()}

{file.originalName}

{formatFileSize(file.size)}

{showRemove && onRemove && ( )}
) : (
{getFileIcon()}

{file.originalName}

{formatFileSize(file.size)}

{showRemove && onRemove && ( )}
)}
); }