import React, { useState } from 'react';
import { Head, Link, router } from '@inertiajs/react';
import EmployerLayout from '../../../Layouts/EmployerLayout';
import {
CheckCircle2,
Globe2,
Briefcase,
DollarSign,
Calendar,
HeartHandshake,
Languages,
MessageSquare,
Bookmark,
ArrowLeft,
Sparkles,
FileText,
ShieldCheck,
Search,
Star,
Share2,
Flag,
X,
UserCheck,
AlertTriangle,
User
} 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 [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("📋 Profile link copied to clipboard!", {
description: "You can now share this URL with your family or sponsor contacts."
});
};
const handleReportSubmit = (e) => {
e.preventDefault();
if (!reportReason) {
toast.error("Please select a reason for reporting.");
return;
}
toast.success("🛡️ Worker report submitted successfully", {
description: "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("Please add a comment.");
return;
}
const newReview = {
id: Date.now(),
employer_name: "You (Verified Sponsor)",
rating: newRating,
date: "Today",
comment: newComment,
};
setWorkerReviews([newReview, ...workerReviews]);
toast.success("⭐ Review posted successfully!", {
description: "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 ? "Removed from Shortlist" : "Added to Shortlist");
}
});
};
const handleMarkHired = () => {
setAvailabilityStatus('Hired');
setShowHiredModal(true);
toast.success("🎉 Worker successfully marked as Hired!", {
description: "Sponsorship direct match finalized. Please leave an anonymous trust review!"
});
};
return (
"{worker.bio}"
Ratings can only be posted by verified sponsors who completed verified direct hiring.
"{review.comment}"
{sim.nationality} • {sim.category}
{worker.name} is successfully marked as Hired under your sponsorship! This direct matching conforms exactly with Stage 4 of our UAE MOHRE zero-middlemen flow.
Help the UAE community hire safely by posting an anonymous review describing {worker.name}'s childcare, cooking, driving, or domestic skills.