import React, { useEffect } from 'react'; import { Link, usePage } from '@inertiajs/react'; import { toast } from 'sonner'; import { LayoutDashboard, Search, Bookmark, MessageSquare, CreditCard, User, LogOut, Bell, CheckCircle, AlertCircle, ArrowRight, UserCheck, Megaphone, Briefcase, Heart, FileText, ChevronDown, LifeBuoy } from 'lucide-react'; import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from '@/components/ui/dropdown-menu'; import { useTranslation, languages } from '../lib/LanguageContext'; export default function EmployerLayout({ children, title, fullPage = false }) { const { url, props } = usePage(); const { auth, unread_messages_count, flash } = props; const { locale, setLocale, t } = useTranslation(); useEffect(() => { if (flash?.success) { toast.success(flash.success); } if (flash?.error) { toast.error(flash.error); } if (flash?.first_login) { // Elegant first login celebratory alert toast.success(`🎉 ${t('welcome_title', 'Welcome to Marketplace!')}`, { description: t('welcome_desc', 'Your employer profile is verified and active with 30 days of Premium Access.'), duration: 6000, }); } }, [flash, t]); const user = auth?.user || { name: 'Guest', company_name: '', email: '', subscription_status: 'active', subscription_expires_at: '', }; const isSubActive = true; const navItems = [ { name: 'Dashboard', translationKey: 'dashboard', href: '/employer/dashboard', icon: LayoutDashboard }, { name: 'Find Workers', translationKey: 'find_workers', href: '/employer/workers', icon: Search }, { name: 'Shortlist', translationKey: 'shortlist', href: '/employer/shortlist', icon: Bookmark }, { name: 'Hired Workers', translationKey: 'candidates', href: '/employer/candidates', icon: UserCheck }, { name: 'Messages', translationKey: 'messages', href: '/employer/messages', icon: MessageSquare, badge: unread_messages_count }, { name: 'Charity Events', translationKey: 'charity_events', href: '/employer/events', icon: Heart }, { name: 'Subscription', translationKey: 'subscription', href: '/employer/subscription', icon: CreditCard }, { name: 'Payment History', translationKey: 'payment_history', href: '/employer/payments', icon: FileText }, { name: 'My Profile', translationKey: 'my_profile', href: '/employer/profile', icon: User }, { name: 'Help & Support', translationKey: 'help_support', href: '/employer/support', icon: LifeBuoy }, ]; const mobileTabs = [ { name: 'Search', translationKey: 'search', href: '/employer/workers', icon: Search }, { name: 'Shortlist', translationKey: 'shortlist', href: '/employer/shortlist', icon: Bookmark }, { name: 'Hired Workers', translationKey: 'candidates', href: '/employer/candidates', icon: UserCheck }, { name: 'Messages', translationKey: 'messages', href: '/employer/messages', icon: MessageSquare, badge: unread_messages_count }, { name: 'Profile', translationKey: 'profile', href: '/employer/profile', icon: User }, ]; return (
{/* Top Subscription Gate Banner */} {!isSubActive && !fullPage && (
{t('sub_warning', 'You need an active subscription to contact workers.')}
{t('subscribe_now', 'Subscribe now')}
)} {/* Mobile Header Navbar */} {!fullPage && (
M
{t('employer_portal', 'Employer Portal')}
{unread_messages_count > 0 && ( )}
{user.name.charAt(0)}
)}
{/* Desktop Sidebar (lg+) */} {/* Main Content Area */}
{/* Top Desktop Header */} {!fullPage && (
{title ? t(title.toLowerCase().replace(/\s+/g, '_'), title) : t('overview', 'Overview')}
{/* Language Switcher Dropdown */} Select Language {languages.map((lang) => ( setLocale(lang.code)} className={`flex items-center justify-between px-2.5 py-2 text-xs font-bold rounded-lg cursor-pointer transition-all ${ locale === lang.code ? 'bg-[#185FA5]/10 text-[#185FA5] font-black' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }`} >
{lang.flag} {lang.nativeName}
{locale === lang.code && (
)} ))} {/* Chat/Notifications */} {/* Profile Section with Dropdown */} {t('my_account', 'My Account')} {t('profile_settings', 'Profile Settings')} {t('subscription', 'Subscription')} {t('sign_out', 'Sign Out')}
)}
{title && !fullPage && (

{title ? t(title.toLowerCase().replace(/\s+/g, '_'), title) : ''}

)} {children}
{/* Mobile Bottom Tab Bar */} {!fullPage && ( )}
); }