d7b5988858
Foundation: - CLAUDE.md with full coding rules (tech stack, patterns, redirect rules) - Install @tanstack/react-query, zod, react-hook-form, shadcn/ui deps - CSS variables design system (Tailwind v4 + tw-animate-css) - Shared components: Button, Input, Label, Card, Badge, Separator, Form - PortalLoginShell: two-column login layout (branding left, form right) - PortalNav: shared sidebar nav used by all portals - ReactQueryProvider in root layout - api-client.ts: typed fetch wrapper (no raw fetch in components) Portal isolation: - Sidebar now returns null for all non-chapter routes; portals own their layout - Admin layout: auth guard + PortalNav (slate accent) - Org layout: auth guard + PortalNav (violet accent) - Member layout: server-side cookie check → MemberNav client component - Chapter admin sidebar: PortalNav (blue accent) Login pages (all use react-hook-form + Zod + PortalLoginShell): - /login → defaults next to /search (was /) — fixes redirect bug - /admin/login → replaces /admin - /org/login → replaces /org - /member-login → two-step phone+OTP with proper form validation Portal selector (/) redesigned with accent border-left cards Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
'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: <LayoutDashboard /> },
|
|
{ href: '/admin/orgs', label: 'Organisations', icon: <Building2 /> },
|
|
{ href: '/admin/tenants', label: 'Chapters', icon: <Building2 /> },
|
|
{ href: '/admin/bots', label: 'Bot Pool', icon: <Server /> },
|
|
{ href: '/admin/drafts', label: 'AI Drafts', icon: <FileText /> },
|
|
];
|
|
|
|
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 (
|
|
<div className="flex h-screen -m-6">
|
|
<div className="w-56 shrink-0 border-r bg-sidebar animate-pulse" />
|
|
<div className="flex-1" />
|
|
</div>
|
|
);
|
|
}
|
|
if (!admin) return null;
|
|
|
|
return (
|
|
<div className="flex h-screen overflow-hidden -m-6">
|
|
<PortalNav
|
|
portalName="Admin"
|
|
navItems={NAV}
|
|
accentClass="text-slate-900"
|
|
user={{ email: admin.email, name: admin.name ?? undefined, role: 'Super Admin' }}
|
|
onLogout={() => { void logout(); router.replace('/admin/login'); }}
|
|
/>
|
|
<main className="flex-1 overflow-auto bg-muted/30 p-6">{children}</main>
|
|
</div>
|
|
);
|
|
}
|