Files
maaz519 205418fc4e 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>
2026-06-20 18:20:06 +05:30

60 lines
2.7 KiB
TypeScript

'use client';
import { useEffect, useState } from 'react';
import { useSuperAdmin } from '@/app/_lib/super-admin-context';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
export default function AdminDashboard() {
const { admin, loading } = useSuperAdmin();
const router = useRouter();
const [tenants, setTenants] = useState<any[]>([]);
const [bots, setBots] = useState<any[]>([]);
useEffect(() => {
if (loading) return;
if (!admin) { router.replace('/admin/login'); return; }
fetch('/api/admin/tenants').then(r => r.ok && r.json()).then(d => setTenants(d ?? [])).catch(() => {});
fetch('/api/admin/bots').then(r => r.ok && r.json()).then(d => setBots(d ?? [])).catch(() => {});
}, [admin, loading, router]);
if (loading) return <p className="text-gray-500">Loading...</p>;
if (!admin) return null;
const totalTenants = tenants.length;
const activeTenants = tenants.filter((t: any) => t.isActive).length;
const totalBots = bots.length;
const totalMessages = tenants.reduce((s: number, t: any) => s + (t.stats?.messages ?? 0), 0);
return (
<div>
<h1 className="text-2xl font-bold mb-6">Admin Dashboard</h1>
<div className="grid grid-cols-4 gap-4 mb-8">
<div className="bg-white rounded-xl border p-4">
<div className="text-xs text-gray-500 uppercase tracking-wide">Tenants</div>
<div className="text-2xl font-bold mt-1">{totalTenants}</div>
<div className="text-xs text-gray-400">{activeTenants} active</div>
</div>
<div className="bg-white rounded-xl border p-4">
<div className="text-xs text-gray-500 uppercase tracking-wide">Bot Accounts</div>
<div className="text-2xl font-bold mt-1">{totalBots}</div>
<div className="text-xs text-gray-400">in pool</div>
</div>
<div className="bg-white rounded-xl border p-4">
<div className="text-xs text-gray-500 uppercase tracking-wide">Messages</div>
<div className="text-2xl font-bold mt-1">{totalMessages}</div>
</div>
<div className="bg-white rounded-xl border p-4">
<div className="text-xs text-gray-500 uppercase tracking-wide">Avg tenants/bot</div>
<div className="text-2xl font-bold mt-1">{totalBots ? Math.round(totalTenants / totalBots) : 0}</div>
</div>
</div>
<div className="flex gap-4 flex-wrap">
<Link href="/admin/tenants" className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm">Manage Tenants</Link>
<Link href="/admin/bots" className="bg-blue-600 text-white rounded-lg px-4 py-2 text-sm">Manage Bots</Link>
<Link href="/admin/drafts" className="bg-indigo-600 text-white rounded-lg px-4 py-2 text-sm">AI Content Drafts</Link>
</div>
</div>
);
}