'use client'; import { useState, useRef } from 'react'; import { Modal } from '@/components/ui'; interface Props { isOpen: boolean; onClose: () => void; onUpload?: (file: File) => void; } export default function FileUploadModal({ isOpen, onClose, onUpload }: Props) { const [file, setFile] = useState(null); const [dragging, setDragging] = useState(false); const inputRef = useRef(null); const handleFile = (f: File) => { setFile(f); }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); setDragging(false); if (e.dataTransfer.files[0]) handleFile(e.dataTransfer.files[0]); }; const handleSubmit = () => { if (file && onUpload) { onUpload(file); setFile(null); onClose(); } }; return ( }>
{ e.preventDefault(); setDragging(true); }} onDragLeave={() => setDragging(false)} className={`border-2 border-dashed rounded-lg p-10 text-center cursor-pointer transition-colors ${dragging ? 'border-primary-500 bg-primary-50' : 'border-gray-300 hover:border-gray-400'}`} onClick={() => inputRef.current?.click()}> { if (e.target.files?.[0]) handleFile(e.target.files[0]); }} className="hidden" /> {file ? (
📄
{file.name}
{(file.size / 1024 / 1024).toFixed(2)} МБ
) : (
📤
Перетащите файл или нажмите
PDF, DOCX, XLSX, CSV, ZIP
)}
); }