import React, { useRef } from 'react'; import { UploadIcon } from 'lucide-react'; interface UploadSectionProps { selectedTest: string; uploadedImage: string | null; setUploadedImage: (image: string | null) => void; selectedModel: string; setSelectedModel: (model: string) => void; onAnalyze: () => void; } export function UploadSection({ selectedTest, uploadedImage, setUploadedImage, selectedModel, setSelectedModel, onAnalyze, }: UploadSectionProps) { const fileInputRef = useRef(null); const modelOptions = { cytology: [ { value: 'mwt', label: 'Manalife_AI_MWT' }, { value: 'yolo', label: 'Manalife_AI_YOLOv8' }, ], colposcopy: [ { value: 'cin', label: 'Manalife_MaANIA_Colpo' }, ], histopathology: [ { value: 'histopathology', label: 'ManalifeAI__Path Foundation Model' }, ], }; const sampleImages = { cytology: [ "/cyto/neg1.bmp", "/cyto/neg2.png", "/cyto/LSIL1.png", "/cyto/LSIL2.png", "/cyto/HSIL1.jpg", "/cyto/HSIL2.JPG", ], colposcopy: [ "/colpo/ab1.jpg", "/colpo/ab2.jpg", "/colpo/ab3.jpg", "/colpo/nor1.jpg", "/colpo/nor2.jpg", "/colpo/nor3.jpg", ], histopathology: [ "/histo/hist1.png", "/histo/hist2.png", "/histo/hist3.jpg", ], }; const currentModels = modelOptions[selectedTest as keyof typeof modelOptions] || []; const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { const reader = new FileReader(); reader.onload = (event) => { setUploadedImage(event.target?.result as string); }; reader.readAsDataURL(file); } }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); const file = e.dataTransfer.files[0]; if (file) { const reader = new FileReader(); reader.onload = (event) => { setUploadedImage(event.target?.result as string); }; reader.readAsDataURL(file); } }; // Handle click on sample image const handleSampleClick = (imgUrl: string) => { setUploadedImage(imgUrl); }; return (

Upload an image of a tissue sample

{/* Upload Area */}
e.preventDefault()} onClick={() => fileInputRef.current?.click()} className="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center cursor-pointer hover:border-blue-400 transition-colors" >
{uploadedImage ? ( <>

Image uploaded successfully!

Click to upload a different image

Uploaded sample
) : (

Drag and drop or click to upload

)}
{/* Model Selection */}
{/* Analyze Button */} {/* Separator */}
{/* Sample Images Section */}

Samples Images

{(sampleImages[selectedTest as keyof typeof sampleImages] || []).map( (img, index) => (
handleSampleClick(img)} > {`Sample
) )}
); }