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
+63
View File
@@ -0,0 +1,63 @@
'use client';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { useOrgAdmin } from '@/app/_lib/org-admin-context';
export default function OrgDashboardPage() {
const { orgAdmin, loading } = useOrgAdmin();
const router = useRouter();
const [data, setData] = useState<any>(null);
useEffect(() => {
if (loading) return;
if (!orgAdmin) { router.replace('/org/login'); return; }
fetch('/api/org/dashboard')
.then((r) => r.ok ? r.json() : null)
.then((d) => setData(d))
.catch(() => {});
}, [orgAdmin, loading, router]);
if (loading || !orgAdmin) return <p className="text-gray-500 p-6">Loading...</p>;
return (
<div>
<h1 className="text-2xl font-bold mb-1">{orgAdmin.organization?.name ?? 'Organization'}</h1>
<p className="text-sm text-gray-500 mb-6">{data?.chapterCount ?? '—'} chapters</p>
<div className="grid gap-4">
{(data?.chapters ?? []).map((chapter: any) => (
<div key={chapter.id} className="bg-white rounded-xl border p-5 flex items-center justify-between">
<div>
<Link href={`/org/tenants/${chapter.id}`} className="font-medium text-blue-600 hover:underline">
{chapter.name}
</Link>
<p className="text-xs text-gray-500 mt-1">{chapter.slug}</p>
</div>
<div className="flex gap-6 text-sm text-right">
<div>
<p className="font-medium">{chapter.messageCount}</p>
<p className="text-xs text-gray-400">messages</p>
</div>
<div>
<p className="font-medium">{chapter.memberCount}</p>
<p className="text-xs text-gray-400">members</p>
</div>
<div>
<p className="font-medium">{chapter.adminCount}</p>
<p className="text-xs text-gray-400">admins</p>
</div>
<span className={`self-center text-xs font-medium px-2 py-1 rounded-full ${chapter.isActive ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'}`}>
{chapter.isActive ? 'Active' : 'Inactive'}
</span>
</div>
</div>
))}
{data && data.chapters.length === 0 && (
<p className="text-gray-400">No chapters yet. <Link href="/org/tenants" className="text-blue-600 hover:underline">Add a chapter</Link>.</p>
)}
</div>
</div>
);
}