import { FileDown } from "lucide-react"; import { useRef, useState } from "react"; interface FileDropZoneProps { onFileSelected: (file: File) => void; } export function FileDropZone({ onFileSelected }: FileDropZoneProps) { const [isDragging, setIsDragging] = useState(false); const fileInputRef = useRef(null); const handleDragEnter = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(true); }; const handleDragLeave = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); }; const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); const files = Array.from(e.dataTransfer.files); const nroFile = files.find((file) => file.name.endsWith(".nro")); if (nroFile) { onFileSelected(nroFile); } else if (files.length > 0) { onFileSelected(files[0]); } }; const handleFileInput = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { onFileSelected(file); } }; const handleClick = () => { fileInputRef.current?.click(); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" || e.key === " ") { handleClick(); } }; return (

{isDragging ? "Drop file now" : "Select NRO File"}

Drag & drop or click to browse

); }