import React, { useState } from 'react'; import { Link, usePage } from '@inertiajs/react'; import { LayoutDashboard, Users, Briefcase, CreditCard, Megaphone, Settings, LogOut, Menu, Shield, BadgeDollarSign, ShieldCheck, ShieldAlert, BellRing, BarChart3, History, List, LifeBuoy, Heart, Building, HelpCircle } from 'lucide-react'; import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'; export default function AdminLayout({ children, title = 'Dashboard' }) { const { url, props } = usePage(); const { auth } = props; const user = auth?.user || { name: 'Admin Portal', email: 'admin@marketplace.com' }; const [open, setOpen] = useState(false); const navItems = [ { name: 'Dashboard', href: '/admin/dashboard', icon: LayoutDashboard }, { name: 'Worker Profiles', href: '/admin/workers', icon: Users }, { name: 'Employers', href: '/admin/employers', icon: Briefcase }, { name: 'Charity Organizations', href: '/admin/charity-organizations', icon: Building }, { name: 'OCR Verification', href: '/admin/workers/verifications', icon: ShieldCheck }, { name: 'Safety & Moderation', href: '/admin/safety', icon: ShieldAlert }, { name: 'Support Tickets', href: '/admin/tickets', icon: LifeBuoy }, { name: 'Frequently Asked Questions', href: '/admin/faqs', icon: HelpCircle }, { name: 'Payments', href: '/admin/payments', icon: BadgeDollarSign }, { name: 'Reports & Analytics', href: '/admin/analytics', icon: BarChart3 }, { name: 'System Audit Logs', href: '/admin/audit-logs', icon: History }, { name: 'Charity Events', href: '/admin/events', icon: Heart }, { name: 'Skills', href: '/admin/master-data/skills', icon: Settings }, { name: 'Reason Master', href: '/admin/master-data/reasons', icon: List }, ]; const getInitials = (name) => { return name ?.split(' ') .map((n) => n[0]) .join('') .toUpperCase() || 'A'; }; const SidebarContent = ({ isMobile }) => (
{/* Top: App Logo + Admin Label */}
Admin Portal
{/* Nav Items */}
{navItems.map((item) => { const Icon = item.icon; const active = url.startsWith(item.href); return ( isMobile && setOpen(false)} className={`flex items-center space-x-3 px-4 py-3 rounded-xl text-sm transition-all duration-200 group ${ active ? 'bg-[#0F6E56] text-white font-bold shadow-lg shadow-teal-900/20 scale-[1.02]' : 'text-gray-500 hover:bg-gray-50 hover:text-gray-900' }`} > {item.name} ); })}
{/* Bottom: Admin Avatar, Name, Email, Logout */}
{getInitials(user.name)}

{user.name}

{user.email}

Log Out
); return (
{/* Fixed Left Sidebar (Desktop lg+) */} {/* Main Content Area */}
{/* Top Bar */}
{/* Mobile menu trigger */}

{title}

{getInitials(user.name)}
{/* Content Slot */}
{children}
); }