import { useCallback } from 'react'; import { useDropzone } from 'react-dropzone'; import { Upload, FileImage, FileText, Loader2 } from 'lucide-react'; import { cn } from '../lib/utils'; import { isDicomFile } from '../lib/api'; interface FileUploadProps { onUpload: (file: File) => void; preview: string | null; currentFile: File | null; isLoading?: boolean; } export function FileUpload({ onUpload, preview, currentFile, isLoading = false }: FileUploadProps) { const onDrop = useCallback( (acceptedFiles: File[]) => { if (acceptedFiles.length > 0) { onUpload(acceptedFiles[0]); } }, [onUpload] ); const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'], 'application/dicom': ['.dcm', '.dicom'], 'application/octet-stream': ['.dcm', '.dicom'], }, maxFiles: 1, }); const isDicom = currentFile ? isDicomFile(currentFile.name) : false; return (
{isLoading ? ( // Loading state for DICOM preview

Loading DICOM preview...

) : preview ? ( // Show preview image - dark background for medical images
Preview

Click or drop to replace

{/* File type badge */}
{isDicom ? 'DICOM' : 'IMAGE'}
) : ( // Empty state / upload prompt

{isDragActive ? 'Drop file here' : 'Drop or click to upload'}

Supports DICOM and image files

{/* Format hints */}
DICOM Best
PNG/JPEG
)}
); }