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

69 lines
2.2 KiB
TypeScript

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>
);
}