import React, { useState } from 'react'; import { Head, Link, router } from '@inertiajs/react'; import EmployerLayout from '../../../Layouts/EmployerLayout'; import { useTranslation } from '../../../lib/LanguageContext'; import { CheckCircle2, Globe2, Briefcase, DollarSign, Calendar, HeartHandshake, Languages, MessageSquare, Bookmark, ArrowLeft, Sparkles, FileText, ShieldCheck, Search, Star, Share2, Flag, X, UserCheck, AlertTriangle, User, Phone } from 'lucide-react'; import { toast } from 'sonner'; const getLanguageFlag = (lang) => { const flags = { 'English': '🇬🇧', 'Arabic': '🇦🇪', 'Tagalog': '🇵🇭', 'Hindi': '🇮🇳', 'Swahili': '🇰🇪', 'French': '🇫🇷', 'Indonesian': '🇮🇩' }; return flags[lang] || '🌐'; }; export default function Show({ worker }) { const { t } = useTranslation(); const passportDoc = worker.documents?.find(d => d.type === 'passport'); const visaDoc = worker.documents?.find(d => d.type === 'visa'); const [showReportModal, setShowReportModal] = useState(false); const [reportReason, setReportReason] = useState(''); const [reportDetails, setReportDetails] = useState(''); const [isShortlisted, setIsShortlisted] = useState(false); // Hiring flow states const [availabilityStatus, setAvailabilityStatus] = useState(worker.availability_status); const [showHiredModal, setShowHiredModal] = useState(false); // Reviews state const [showReviewModal, setShowReviewModal] = useState(false); const [newRating, setNewRating] = useState(5); const [newComment, setNewComment] = useState(''); const [workerReviews, setWorkerReviews] = useState(worker.reviews || []); const handleShare = () => { navigator.clipboard.writeText(window.location.href); toast.success(t('profile_link_copied', 'Profile link copied to clipboard!'), { description: t('profile_link_copied_desc', 'You can now share this URL with your family or sponsor contacts.') }); }; const handleReportSubmit = (e) => { e.preventDefault(); if (!reportReason) { toast.error(t('select_report_reason', 'Please select a reason for reporting.')); return; } toast.success(t('report_submitted', 'Worker report submitted successfully'), { description: t('report_submitted_desc', "Our admin compliance team will investigate this worker's credentials within 24 hours.") }); setShowReportModal(false); setReportReason(''); setReportDetails(''); }; const handleReviewSubmit = (e) => { e.preventDefault(); if (!newComment.trim()) { toast.error(t('add_comment', 'Please add a comment.')); return; } const newReview = { id: Date.now(), employer_name: t('you_verified_sponsor', 'You (Verified Sponsor)'), rating: newRating, date: t('today', 'Today'), comment: newComment, }; setWorkerReviews([newReview, ...workerReviews]); toast.success(t('review_posted', 'Review posted successfully!'), { description: t('review_posted_desc', 'Your trust feedback is live and helps other sponsors hire securely.') }); setShowReviewModal(false); setNewComment(''); }; const handleToggleShortlist = () => { setIsShortlisted(!isShortlisted); router.post('/employer/shortlist/toggle', { worker_id: worker.id }, { preserveScroll: true, onSuccess: () => { toast.success(isShortlisted ? t('removed_from_shortlist', 'Removed from Shortlist') : t('added_to_shortlist', 'Added to Shortlist')); } }); }; const handleMarkHired = () => { router.post(`/employer/workers/${worker.id}/mark-hired`, {}, { preserveScroll: true, onSuccess: () => { setAvailabilityStatus('Hired'); setShowHiredModal(true); toast.success(t('marked_hired', 'Worker successfully marked as Hired!'), { description: t('marked_hired_desc', 'Sponsorship direct match finalized. Please leave an anonymous trust review!') }); } }); }; return (
{/* Back Link */}
{t('back_to_find_workers', 'BACK TO FIND WORKERS')} {/* Quick Profile Actions */}
{/* Header Card with Clean Premium White BG */}
{worker.photo ? ( {worker.name} ) : ( )}

{worker.name}

{worker.verified && ( {t('verified')} )}
{/* Passport verification status bar & Visa Status */}
{worker.passport_status}
{worker.visa_status && (worker.visa_status.toLowerCase().includes('tourist') || worker.visa_status.toLowerCase().includes('visit')) ? (
{worker.visa_status} ({t('warning', 'Warning')}: {t('visit_visa', 'Visit Visa')})
) : worker.visa_status && worker.visa_status.toLowerCase().includes('cancelled') ? (
{worker.visa_status} ({t('warning', 'Warning')}: {t('cancelled', 'Cancelled')})
) : (
{worker.visa_status}
)}
{worker.nationality} {worker.age} {t('years_old', 'Years Old')} {worker.category}
{worker.rating} / 5.0 ({workerReviews.length} {t('reviews', 'reviews')})
{/* Sponsor Actions Block */}
{/* Stage 3 Connect: Start In-App Chat */} {t('start_direct_chat', 'Start Direct Chat')} {/* Stage 4 Hire: Mark Hired (Finalize Hiring Direct Flow) */} {availabilityStatus !== 'Hired' && ( )}
{/* Main Details Grid */}
{/* Left Column: Quick Stats */}

{t('worker_details_title', 'Worker Details')}

{t('name', 'Name')}
{worker.name}
{t('mobile', 'Mobile')}
{worker.phone}
{t('gender', 'Gender')}
{worker.gender}
{t('salary_expectations', 'Salary Expectations')}
{worker.salary} {t('aed', 'AED')} / {t('mo', 'mo')}
{t('work_experience', 'Work Experience')}
{worker.experience}
{t('job_type', 'Job Type')}
{worker.preferred_job_type}
{t('accommodation_preference', 'Accommodation Preference')}
{worker.live_in_out}
{t('passport_verification', 'Passport Verification')}
{worker.passport_status}
{t('visa_status', 'Visa Status')}
{worker.visa_status}
{t('medical_health_test', 'Medical Health Test')}
{t('passed_certified', 'PASSED CERTIFIED')}
{/* Languages Spoken with visual flags */}
{t('languages_spoken', 'Languages Spoken')}
{worker.languages?.map(lang => ( {getLanguageFlag(lang)} {lang} ))}
{/* Right Column: Bio & Skills */}
{/* Professional Summary */}

{t('professional_summary', 'Professional Summary')}

"{worker.bio}"

{/* Verified Skills & Competencies */}

{t('verified_skills_competencies', 'Verified Skills & Competencies')}

{worker.skills?.map(skill => (
{skill}
))}
{/* Verified Documents Section */}

{t('verified_legal_docs', 'Verified Legal Documents (UAE MOHRE Vetted)')}

{/* Document Card: Passport */}
{t('passport_verified', 'Passport (PDPL Compliant)')}
{t('scan_purged', 'Scan Purged')} {t('uae_pdpl_compliant', 'UAE PDPL compliant')}
{t('document_id', 'Document ID')}
{passportDoc?.number || 'L82739102-UAE'}
{t('issue_date', 'Issue')}
{passportDoc?.issue_date || '12 Jan 2021'}
{t('expiry_date', 'Expiry')}
{passportDoc?.expiry_date || '11 Jan 2031'}
{t('ocr_match', 'OCR Match')}
{passportDoc?.ocr_accuracy || 95}%
{t('physical_scan_storage', 'Physical Scan Storage')}
{t('permanently_purged', 'Permanently Purged')}
{/* Document Card: Visa */}
{t('entry_visa_verified', 'Entry Visa (PDPL Compliant)')} {worker.visa_status && (worker.visa_status.toLowerCase().includes('tourist') || worker.visa_status.toLowerCase().includes('visit') || worker.visa_status.toLowerCase().includes('cancelled')) ? ( ) : ( )}
{t('scan_purged', 'Scan Purged')} {t('uae_pdpl_compliant', 'UAE PDPL compliant')}
{t('document_id', 'Document ID')}
{visaDoc?.number || 'V2839102-DXB'}
{t('issue_date', 'Issue')}
{visaDoc?.issue_date || '12 Jan 2023'}
{t('expiry_date', 'Expiry')}
{visaDoc?.expiry_date || '11 Jan 2026'}
{t('visa_category', 'Visa Category')}
{worker.visa_status}
{t('verification_status', 'Verification status')}
{worker.visa_status && (worker.visa_status.toLowerCase().includes('tourist') || worker.visa_status.toLowerCase().includes('visit')) ? ( {t('transfer_required', 'Transfer Required')} ) : worker.visa_status && worker.visa_status.toLowerCase().includes('cancelled') ? ( {t('needs_regularization', 'Needs Regularization')} ) : ( <> {t('clear_records', 'Clear Records')} )}
{/* Star Ratings & Trust Review logs */}

{t('sponsor_reviews_star_ratings', 'Sponsor Reviews & Star Ratings')}

{t('reviews_posted_by_sponsors_desc', 'Ratings can only be posted by verified sponsors who completed verified direct hiring.')}

{/* Reviews List */}
{workerReviews.map((review) => (
{review.employer_name} {review.date}
{[...Array(5)].map((_, i) => ( ))}

"{review.comment}"

))}
{/* Similar Recommendations Slider */}

{t('similar_recommended_workers', 'Similar Recommended Workers')}

{worker.similar_workers?.map((sim) => (

{sim.name}

{sim.nationality} • {sim.category}

{sim.verified && ( {t('verified', 'Verified')} )}
{sim.salary} {t('aed', 'AED')}/{t('mo', 'mo')} {t('view_profile', 'View Profile')}
))}
{/* Stage 4/5 Hired Flow Success Modal Overlay */} {showHiredModal && (

{t('direct_sponsoring_finalized', 'Direct Sponsoring Finalized!')}

{t('hired_under_sponsorship_desc', '{name} is successfully marked as Hired under your sponsorship! This direct matching conforms exactly with Stage 4 of our UAE MOHRE zero-middlemen flow.').replace('{name}', worker.name)}

{t('next_step_post_hire_review', 'Next Step: Stage 5 Post-Hire Review')}

{t('help_community_post_review', "Help the UAE community hire safely by posting an anonymous review describing {name}'s childcare, cooking, driving, or domestic skills.").replace('{name}', worker.name)}

{t('back_to_worker_directory', 'Back to Worker Directory')}
)} {/* Report Abuse Modal Overlay */} {showReportModal && (

{t('report_abuse_violation', 'Report Verification Abuse / Terms Violation')}

{t('zero_tolerance_abuse_desc', 'We maintain zero-tolerance for fake documentation, independent recruiters trading cash, or incorrect contact details.')}