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>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
'use client';
|
|
|
|
import { usePathname, useRouter } from 'next/navigation';
|
|
import { useEffect } from 'react';
|
|
import { useAuth } from './auth-context';
|
|
import { PortalNav } from '../_components/portal-nav';
|
|
import {
|
|
Search, Users, MessageSquare, FileText, Settings, Bot,
|
|
LayoutDashboard, Building2, Server, Inbox,
|
|
} from 'lucide-react';
|
|
|
|
// Paths that render their own full-screen layout (no sidebar)
|
|
const FULLSCREEN_PATHS = ['/', '/login', '/member-login', '/onboard', '/admin/login', '/org/login', '/org', '/admin', '/my'];
|
|
|
|
const CHAPTER_NAV = [
|
|
{ href: '/search', label: 'Search', icon: <Search /> },
|
|
{ href: '/groups', label: 'Groups & Routes', icon: <Users /> },
|
|
{ href: '/messages/pending', label: 'Pending', icon: <Inbox /> },
|
|
{ href: '/drafts', label: 'AI Drafts', icon: <FileText /> },
|
|
{ href: '/settings/rules', label: 'Rules', icon: <Settings /> },
|
|
{ href: '/settings/bot', label: 'Bot', icon: <Bot /> },
|
|
];
|
|
|
|
export function Sidebar() {
|
|
const { admin, loading, logout } = useAuth();
|
|
const pathname = usePathname();
|
|
const router = useRouter();
|
|
|
|
const isFullscreen = FULLSCREEN_PATHS.some((p) =>
|
|
p === '/' ? pathname === '/' : pathname === p || pathname.startsWith(p + '/'),
|
|
);
|
|
|
|
useEffect(() => {
|
|
if (loading || isFullscreen) return;
|
|
if (!admin) router.replace(`/login?next=${encodeURIComponent(pathname)}`);
|
|
}, [loading, admin, pathname, router, isFullscreen]);
|
|
|
|
if (isFullscreen) return null;
|
|
|
|
if (loading) {
|
|
return (
|
|
<div className="w-56 shrink-0 border-r bg-sidebar animate-pulse" />
|
|
);
|
|
}
|
|
|
|
if (!admin) return null;
|
|
|
|
return (
|
|
<PortalNav
|
|
portalName="Chapter"
|
|
navItems={CHAPTER_NAV}
|
|
accentClass="text-blue-600"
|
|
user={{ email: admin.email, name: admin.name ?? undefined, role: admin.role }}
|
|
onLogout={() => { void logout(); router.replace('/login'); }}
|
|
/>
|
|
);
|
|
}
|