import React, { useState } from 'react'; import { Head, Link, router } from '@inertiajs/react'; import axios from 'axios'; import { toast } from 'sonner'; import { Loader2, ShieldAlert, ShieldCheck, UploadCloud, FileText, Users, DollarSign, MessageSquare, ArrowLeft } from 'lucide-react'; export default function UploadEmiratesId({ email }) { const [frontFile, setFrontFile] = useState(null); const [backFile, setBackFile] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleFrontFileChange = (e) => { const selectedFile = e.target.files[0]; if (selectedFile) { if (selectedFile.size > 10240 * 1024) { setError('The document must not exceed 10MB.'); toast.error('The document must not exceed 10MB.'); return; } setFrontFile(selectedFile); setError(null); } }; const handleBackFileChange = (e) => { const selectedFile = e.target.files[0]; if (selectedFile) { if (selectedFile.size > 10240 * 1024) { setError('The document must not exceed 10MB.'); toast.error('The document must not exceed 10MB.'); return; } setBackFile(selectedFile); setError(null); } }; const handleSubmit = async (e) => { e.preventDefault(); if (!frontFile || !backFile) { setError('Please upload both the front and back side of your Emirates ID.'); toast.error('Please upload both sides of your Emirates ID.'); return; } setLoading(true); setError(null); const formData = new FormData(); formData.append('emirates_id_front', frontFile); formData.append('emirates_id_back', backFile); try { await axios.post('/employer/upload-emirates-id', formData, { headers: { 'Content-Type': 'multipart/form-data' } }); toast.success('Emirates ID scanned successfully. Data extracted and document deleted.'); router.visit('/employer/register-payment'); } catch (err) { if (err.response && err.response.data && err.response.data.errors) { const errors = err.response.data.errors; const errorMsg = errors.emirates_id_front?.[0] || errors.emirates_id_back?.[0] || 'Validation failed.'; setError(errorMsg); toast.error('Validation failed. Please verify the document.'); } else { toast.error('Scan extraction failed. Please try again.'); } } finally { setLoading(false); } }; const renderStepIndicator = () => (
{[ { step: 1, label: 'Register' }, { step: 2, label: 'Verify' }, { step: 3, label: 'Emirates ID' }, { step: 4, label: 'Payment' }, { step: 5, label: 'Password' } ].map((s) => (
{s.step}
{s.step === 3 && ( {s.label} )}
{s.step < 5 && (
)} ))}
); return (
{/* Left Brand Panel (Desktop Only) */}
M
Migrant Portal
Employer Registration

Find verified domestic workers directly.

Unlock direct access to top domestic candidates with a Migrant premium subscription. Find, interview, and hire directly without middlemen.

{/* Stat Row */}
500+
Verified Workers
Premium
Employer Access
Direct
Messaging
© 2026 Migrant. All rights reserved.
{/* Right Form Container */}
{renderStepIndicator()}

Emirates ID Verification

Upload your identity document for quick OCR scanning

{/* Security & Disclaimer Banner */}

Data Privacy Disclaimer

We do not store your physical Emirates ID document. Your card is temporarily scanned only to securely extract the ID number and expiry date via automated OCR, and the file is permanently deleted immediately after extraction.

{/* Front Side Upload */}
{!frontFile ? (

Click or Drag front image here

Supported: JPG, JPEG, PNG, PDF (Max 10MB)

) : (

{frontFile.name}

{(frontFile.size / (1024 * 1024)).toFixed(2)} MB • Front Ready

)}
{/* Back Side Upload */}
{!backFile ? (

Click or Drag back image here

Supported: JPG, JPEG, PNG, PDF (Max 10MB)

) : (

{backFile.name}

{(backFile.size / (1024 * 1024)).toFixed(2)} MB • Back Ready

)}
{error && (

{error}

)}
Change Email / Back
); }