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 (
{error}
)} {!error && threads.length === 0 && (No threads yet. Threads are created automatically when members reply to messages.
)} {threads.length > 0 && ({thread.topic ?? `Thread ${thread.id.slice(0, 8)}`}
{thread.sourceGroupName}
{new Date(thread.lastActivityAt).toLocaleDateString()}