'use client'; import { useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { useSuperAdmin } from '../_lib/super-admin-context'; import { PortalNav } from '../_components/portal-nav'; import { LayoutDashboard, Building2, Server, FileText } from 'lucide-react'; const NAV = [ { href: '/admin', label: 'Dashboard', icon: }, { href: '/admin/orgs', label: 'Organisations', icon: }, { href: '/admin/tenants', label: 'Chapters', icon: }, { href: '/admin/bots', label: 'Bot Pool', icon: }, { href: '/admin/drafts', label: 'AI Drafts', icon: }, ]; export default function AdminLayout({ children }: { children: React.ReactNode }) { const { admin, loading, logout } = useSuperAdmin(); const router = useRouter(); useEffect(() => { if (!loading && !admin) router.replace('/admin/login'); }, [admin, loading, router]); if (loading) { return (
); } if (!admin) return null; return (
{ void logout(); router.replace('/admin/login'); }} />
{children}
); }