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
@@ -0,0 +1,107 @@
import Link from 'next/link';
import { apiFetch } from '@/app/_lib/api';
interface ThreadMessage {
id: string;
content: string;
senderJid: string;
senderName: string | null;
tags: string[];
status: string;
createdAt: string;
}
interface ThreadDetail {
id: string;
topic: string | null;
sourceGroupName: string;
messageCount: number;
lastActivityAt: string;
createdAt: string;
messages: ThreadMessage[];
}
const STATUS_COLORS: Record<string, string> = {
APPROVED: 'text-green-600',
PENDING: 'text-amber-600',
REJECTED: 'text-red-600',
RAW: 'text-gray-400',
DNC: 'text-gray-400',
DISTRIBUTED: 'text-blue-600',
};
export default async function ThreadDetailPage({
params,
}: {
params: Promise<{ id: string }>;
}) {
const { id } = await params;
let thread: ThreadDetail | null = null;
let error: string | null = null;
try {
const res = await apiFetch(`/admin/threads/${id}`);
if (res.ok) {
thread = await res.json();
} else {
error = `API returned ${res.status}`;
}
} catch {
error = 'Failed to load thread';
}
if (error || !thread) {
return (
<div className="max-w-2xl">
<Link href="/threads" className="text-sm text-blue-600 hover:underline mb-4 inline-block">&larr; Back to threads</Link>
<p className="text-red-600 text-sm">{error ?? 'Thread not found'}</p>
</div>
);
}
return (
<div className="max-w-2xl">
<Link href="/threads" className="text-sm text-blue-600 hover:underline mb-4 inline-block">&larr; Back to threads</Link>
<div className="mb-6">
<h1 className="text-xl font-semibold">
{thread.topic ?? `Thread ${thread.id.slice(0, 8)}`}
</h1>
<p className="text-sm text-gray-500 mt-1">
{thread.sourceGroupName} &middot; {thread.messageCount} messages &middot; last activity {new Date(thread.lastActivityAt).toLocaleDateString()}
</p>
</div>
<div className="flex flex-col gap-3">
{thread.messages.map((msg) => (
<div key={msg.id} className="border border-gray-200 rounded-lg p-4">
<div className="flex items-center justify-between mb-2">
<div className="text-xs text-gray-500">
<span className="font-medium text-gray-700">{msg.senderName ?? msg.senderJid}</span>
<span className="mx-1">&middot;</span>
<span>{new Date(msg.createdAt).toLocaleString()}</span>
</div>
<div className="flex items-center gap-2">
<span className={`text-xs font-medium ${STATUS_COLORS[msg.status] ?? 'text-gray-500'}`}>
{msg.status}
</span>
<Link href={`/messages/${msg.id}`} className="text-xs text-blue-600 hover:underline">
View
</Link>
</div>
</div>
<p className="text-sm text-gray-900 whitespace-pre-wrap">{msg.content}</p>
{msg.tags.length > 0 && (
<div className="flex flex-wrap gap-1 mt-2">
{msg.tags.map((tag) => (
<span key={tag} className="rounded-full bg-blue-50 px-2 py-0.5 text-xs text-blue-600">{tag}</span>
))}
</div>
)}
</div>
))}
</div>
</div>
);
}
+68
View File
@@ -0,0 +1,68 @@
import Link from 'next/link';
import { apiFetch } from '@/app/_lib/api';
interface ThreadSummary {
id: string;
topic: string | null;
sourceGroupName: string;
messageCount: number;
lastActivityAt: string;
createdAt: string;
}
export default async function ThreadsPage() {
let threads: ThreadSummary[] = [];
let error: string | null = null;
try {
const res = await apiFetch('/admin/threads');
if (res.ok) {
threads = await res.json();
} else {
error = `API returned ${res.status}`;
}
} catch {
error = 'Failed to load threads';
}
return (
<div className="max-w-4xl">
<h1 className="text-xl font-semibold mb-6">Threads</h1>
{error && (
<p className="text-red-600 text-sm mb-4">{error}</p>
)}
{!error && threads.length === 0 && (
<p className="text-gray-500 text-sm">No threads yet. Threads are created automatically when members reply to messages.</p>
)}
{threads.length > 0 && (
<div className="border border-gray-200 rounded-lg divide-y divide-gray-100">
{threads.map((thread) => (
<Link
key={thread.id}
href={`/threads/${thread.id}`}
className="flex items-start justify-between p-4 hover:bg-gray-50 transition-colors"
>
<div className="min-w-0 flex-1">
<p className="text-sm font-medium text-gray-900 truncate">
{thread.topic ?? `Thread ${thread.id.slice(0, 8)}`}
</p>
<p className="text-xs text-gray-500 mt-0.5">{thread.sourceGroupName}</p>
</div>
<div className="ml-4 shrink-0 text-right">
<span className="inline-flex items-center rounded-full bg-blue-50 px-2.5 py-0.5 text-xs font-medium text-blue-700">
{thread.messageCount} {thread.messageCount === 1 ? 'message' : 'messages'}
</span>
<p className="text-xs text-gray-400 mt-1">
{new Date(thread.lastActivityAt).toLocaleDateString()}
</p>
</div>
</Link>
))}
</div>
)}
</div>
);
}