import Link from 'next/link'; import { apiFetch } from '../_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 (

Threads

{error && (

{error}

)} {!error && threads.length === 0 && (

No threads yet. Threads are created automatically when members reply to messages.

)} {threads.length > 0 && (
{threads.map((thread) => (

{thread.topic ?? `Thread ${thread.id.slice(0, 8)}`}

{thread.sourceGroupName}

{thread.messageCount} {thread.messageCount === 1 ? 'message' : 'messages'}

{new Date(thread.lastActivityAt).toLocaleDateString()}

))}
)}
); }