import React, { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { FileUp, X } from "lucide-react"; interface UploadDocProps { isOpen: boolean; onClose: () => void; onUpload: (file: File) => void; } const UploadDoc = ({ isOpen, onClose, onUpload }: UploadDocProps) => { const [selectedFile, setSelectedFile] = useState(null); const [dragActive, setDragActive] = useState(false); const handleDrag = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); const file = e.dataTransfer.files[0]; if (file && file.type === "application/pdf") { setSelectedFile(file); } else { alert("Hanya file PDF yang diperbolehkan"); } }; const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file && file.type === "application/pdf") { setSelectedFile(file); } else { alert("Hanya file PDF yang diperbolehkan"); } }; const handleUpload = () => { if (selectedFile) { onUpload(selectedFile); onClose(); } }; return ( Lampiran *
Silahkan unggah dokumen Anda dengan drag & drop semua berkas atau klik pada kotak ini. Ukuran file tidak boleh melebihi 20 MB.

Drag and drop file PDF di sini atau

{selectedFile && (
{selectedFile.name}
)}
); }; export default UploadDoc;