feat: isolate all four portals with route groups + polished design system

Fix blank /org/login (and /admin/login): the guarded portal layout was
wrapping its own login route, rendering null when unauthenticated. Move
each portal's authed pages into a (authed)/(chapter) route group so login
pages live outside the guard.

Structure:
- app/(chapter)/* — chapter admin pages + guarded layout (was root-level)
- app/org/(authed)/* — org pages + guarded layout; /org/login now free
- app/admin/(authed)/* — admin pages + guarded layout; /admin/login free
- Root layout slimmed to providers only (no shared sidebar)
- Convert moved files' relative imports to @/app alias

Design system:
- PortalShell: shared sidebar shell (brand mark, themed active nav with
  accent bar, avatar dropdown user menu, loading skeletons)
- portal-theme.ts: per-portal theme tokens (violet/slate/blue/emerald)
- PortalLoginShell redesigned: two-column with gradient branding panel,
  dotted pattern, value-prop highlights, built-in back link
- New shadcn components: Avatar, DropdownMenu, Skeleton
- Move shared DraftCard to _components/draft-card.tsx (used by 2 portals)
- Portal selector: remove Super Admin card, icon tiles, hover lift
- All 4 login pages use react-hook-form + Zod + themed shell
- Member nav restored to full 11-section list with icons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 18:20:06 +05:30
parent d7b5988858
commit 205418fc4e
50 changed files with 619 additions and 360 deletions
+36
View File
@@ -0,0 +1,36 @@
'use client';
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
import { PortalShell } from '@/app/_components/portal-shell';
import { LayoutDashboard, Building2, Shield } from 'lucide-react';
const NAV = [
{ href: '/org', label: 'Dashboard', icon: <LayoutDashboard /> },
{ href: '/org/tenants', label: 'Chapters', icon: <Building2 /> },
{ href: '/org/rules', label: 'Org Rules', icon: <Shield /> },
];
export default function OrgAuthedLayout({ children }: { children: React.ReactNode }) {
const { orgAdmin, loading, logout } = useOrgAdmin();
const router = useRouter();
useEffect(() => {
if (!loading && !orgAdmin) router.replace('/org/login');
}, [orgAdmin, loading, router]);
return (
<PortalShell
portalName="Organisation"
theme="violet"
navItems={NAV}
loading={loading}
authed={!!orgAdmin}
user={orgAdmin ? { email: orgAdmin.email, name: orgAdmin.name, role: orgAdmin.role, subtitle: orgAdmin.organization?.name } : undefined}
onLogout={() => { void logout(); router.replace('/org/login'); }}
>
{children}
</PortalShell>
);
}
@@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { useOrgAdmin } from '../_lib/org-admin-context';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
export default function OrgDashboardPage() {
const { orgAdmin, loading } = useOrgAdmin();
@@ -2,7 +2,7 @@
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { useOrgAdmin } from '../../_lib/org-admin-context';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
const MATCH_TYPES = ['HASHTAG', 'PREFIX', 'REACTION_EMOJI'];
const ACTIONS = ['FLAG', 'AUTO_APPROVE', 'SKIP', 'REJECT', 'P1'];
@@ -2,7 +2,7 @@
import { use, useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { useOrgAdmin } from '../../../_lib/org-admin-context';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
export default function OrgTenantDetailPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = use(params);
@@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { useOrgAdmin } from '../../_lib/org-admin-context';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
export default function OrgTenantsPage() {
const { orgAdmin, loading } = useOrgAdmin();
-45
View File
@@ -1,45 +0,0 @@
'use client';
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useOrgAdmin } from '../_lib/org-admin-context';
import { PortalNav } from '../_components/portal-nav';
import { LayoutDashboard, Building2, Shield } from 'lucide-react';
const NAV = [
{ href: '/org', label: 'Dashboard', icon: <LayoutDashboard /> },
{ href: '/org/tenants', label: 'Chapters', icon: <Building2 /> },
{ href: '/org/rules', label: 'Org Rules', icon: <Shield /> },
];
export default function OrgLayout({ children }: { children: React.ReactNode }) {
const { orgAdmin, loading, logout } = useOrgAdmin();
const router = useRouter();
useEffect(() => {
if (!loading && !orgAdmin) router.replace('/org/login');
}, [orgAdmin, 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 (!orgAdmin) return null;
return (
<div className="flex h-screen overflow-hidden -m-6">
<PortalNav
portalName="Org"
navItems={NAV}
accentClass="text-violet-600"
user={{ email: orgAdmin.email, name: orgAdmin.name ?? undefined, role: orgAdmin.role }}
onLogout={() => { void logout(); router.replace('/org/login'); }}
/>
<main className="flex-1 overflow-auto bg-muted/30 p-6">{children}</main>
</div>
);
}
+2 -3
View File
@@ -9,7 +9,6 @@ import { PortalLoginShell } from '../../_components/portal-login-shell';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../../_components/ui/form';
import { Input } from '../../_components/ui/input';
import { Button } from '../../_components/ui/button';
import Link from 'next/link';
const schema = z.object({
email: z.string().email('Enter a valid email'),
@@ -36,8 +35,8 @@ export default function OrgLoginPage() {
<PortalLoginShell
title="Organisation Portal"
subtitle="Manage your chapters, admins and org-wide rules."
accentClass="bg-violet-600"
footer={<Link href="/" className="hover:text-foreground transition-colors"> Back to portal selector</Link>}
theme="violet"
highlights={['Create and oversee chapters', 'Set org-wide routing rules', 'Provision chapter admins']}
>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">