import { Outlet, Link, useLocation, useNavigate } from "react-router-dom" import { useEffect, useState } from "react" import { LayoutDashboard, Users, FileText, Settings, Wrench, Megaphone, Shield, BarChart3, Activity, Heart, Search, Mail, Bell, LogOut, } from "lucide-react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { cn } from "@/lib/utils" import { adminApiHelpers } from "@/lib/api-client" interface User { email: string firstName?: string lastName?: string role: string } const adminNavigationItems = [ { icon: LayoutDashboard, label: "Dashboard", path: "/admin/dashboard" }, { icon: Users, label: "Users", path: "/admin/users" }, { icon: FileText, label: "Logs", path: "/admin/logs" }, { icon: Settings, label: "Settings", path: "/admin/settings" }, { icon: Wrench, label: "Maintenance", path: "/admin/maintenance" }, { icon: Megaphone, label: "Announcements", path: "/admin/announcements" }, { icon: Activity, label: "Audit", path: "/admin/audit" }, { icon: Shield, label: "Security", path: "/admin/security" }, { icon: BarChart3, label: "Analytics", path: "/admin/analytics" }, { icon: Heart, label: "System Health", path: "/admin/health" }, ] export function AppShell() { const location = useLocation() const navigate = useNavigate() const [user, setUser] = useState(null) useEffect(() => { const userStr = localStorage.getItem('user') if (userStr) { try { setUser(JSON.parse(userStr)) } catch (error) { console.error('Failed to parse user data:', error) } } }, []) const isActive = (path: string) => { return location.pathname.startsWith(path) } const getPageTitle = () => { const currentPath = location.pathname const item = adminNavigationItems.find((item) => currentPath.startsWith(item.path) ) return item?.label || "Admin Panel" } const handleLogout = () => { adminApiHelpers.logout() navigate('/login', { replace: true }) } const getUserInitials = () => { if (user?.firstName && user?.lastName) { return `${user.firstName[0]}${user.lastName[0]}`.toUpperCase() } if (user?.email) { return user.email.substring(0, 2).toUpperCase() } return 'AD' } const getUserDisplayName = () => { if (user?.firstName && user?.lastName) { return `${user.firstName} ${user.lastName}` } return user?.email || 'Admin User' } return (
{/* Sidebar */} {/* Main Content */}
{/* Top Header */}

{getPageTitle()}

{getUserInitials()}
{/* Page Content */}
) }