function CandidateModal({ open, onClose }) { const [submitted, setSubmitted] = React.useState(false); const [uploading, setUploading] = React.useState(false); const [error, setError] = React.useState(''); const [fileName, setFileName] = React.useState(''); const [dragOver, setDragOver] = React.useState(false); const fileRef = React.useRef(null); const nameRef = React.useRef(null); const emailRef = React.useRef(null); const areaRef = React.useRef(null); React.useEffect(() => { if (!open) { setSubmitted(false); setError(''); setFileName(''); setUploading(false); } }, [open]); const handleFile = (file) => { if (!file) return; const allowed = ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']; if (!allowed.includes(file.type)) { setError('Please upload a PDF, DOC, or DOCX file.'); return; } if (file.size > 10 * 1024 * 1024) { setError('File must be under 10 MB.'); return; } setError(''); setFileName(file.name); const dt = new DataTransfer(); dt.items.add(file); fileRef.current.files = dt.files; }; const handleDrop = (e) => { e.preventDefault(); setDragOver(false); handleFile(e.dataTransfer.files[0]); }; const handleSubmit = async () => { const name = nameRef.current.value.trim(); const email = emailRef.current.value.trim(); const area = areaRef.current.value; if (!name || !email) { setError('Please fill in your name and email.'); return; } if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { setError('Please enter a valid email address.'); return; } const formData = new FormData(); formData.append('name', name); formData.append('email', email); formData.append('area', area); if (fileRef.current.files[0]) formData.append('resume', fileRef.current.files[0]); setUploading(true); setError(''); try { const res = await fetch('/api/candidate', { method: 'POST', body: formData }); if (res.ok) { setSubmitted(true); } else { const d = await res.json().catch(() => ({})); setError(d.error || 'Submission failed. Please try again.'); } } catch (e) { setError('Network error. Please try again.'); } finally { setUploading(false); } }; return (
Submit your profile and we'll connect you with relevant opportunities. All submissions are treated as strictly confidential.
{error}
} > ) : (We'll be in touch when a relevant opportunity arises. All profiles are treated as strictly confidential.