'use client'; import { useEffect } from 'react'; import { usePathname, useRouter } from 'next/navigation'; import { useAuth } from '@/app/_lib/auth-context'; import { PortalShell } from '@/app/_components/portal-shell'; import { Search, Users, Inbox, FileText, SlidersHorizontal, Bot } from 'lucide-react'; const NAV = [ { href: '/search', label: 'Search', icon: }, { href: '/groups', label: 'Groups & Routes', icon: }, { href: '/messages/pending', label: 'Pending', icon: }, { href: '/drafts', label: 'AI Drafts', icon: }, { href: '/settings/rules', label: 'Rules', icon: }, { href: '/settings/bot', label: 'Bot', icon: }, ]; export default function ChapterLayout({ children }: { children: React.ReactNode }) { const { admin, loading, logout } = useAuth(); const router = useRouter(); const pathname = usePathname(); useEffect(() => { if (!loading && !admin) router.replace(`/login?next=${encodeURIComponent(pathname)}`); }, [admin, loading, pathname, router]); return ( { void logout(); router.replace('/login'); }} > {children} ); }