'use client'; import { ReactNode, useState } from 'react'; import { LayoutDashboard, Users, Settings, LogOut, Shield, Activity } from 'lucide-react'; import { useRouter, usePathname } from 'next/navigation'; interface AdminLayoutProps { children: ReactNode; } type AdminTab = 'dashboard' | 'users'; export function AdminLayout({ children }: AdminLayoutProps) { const router = useRouter(); const pathname = usePathname(); const [isSidebarOpen, setIsSidebarOpen] = useState(true); // Determine current tab from pathname const getCurrentTab = (): AdminTab => { if (pathname === '/admin') return 'dashboard'; if (pathname === '/admin/users') return 'users'; return 'dashboard'; }; const currentTab = getCurrentTab(); const navigation = [ { id: 'dashboard', label: 'Dashboard', icon: LayoutDashboard, href: '/admin', description: 'Overview and statistics' }, { id: 'users', label: 'User Management', icon: Users, href: '/admin/users', description: 'Manage all users' }, { id: 'settings', label: 'Settings', icon: Settings, href: '/admin/settings', description: 'System configuration', disabled: true } ]; const handleNavigation = (href: string, disabled?: boolean) => { if (!disabled) { router.push(href); } }; const handleLogout = async () => { try { await fetch('/api/auth/logout', { method: 'POST' }); router.push('/'); } catch (error) { console.error('Logout failed:', error); } }; return (
{/* Sidebar */} {/* Main Content */}
{/* Top Bar */}

{navigation.find(n => n.id === currentTab)?.label || 'Admin'}

{navigation.find(n => n.id === currentTab)?.description}

Super Admin
System Administrator
Full Access
{/* Content Area */}
{children}
); }