import Link from 'next/link' import { createClient } from '@/lib/supabase/server' import { Pin, Lock, MessagesSquare, Plus } from 'lucide-react' export default async function ForumIndexPage() { const supabase = await createClient() const { data: { user } } = await supabase.auth.getUser() if (!user) return null const { data: self } = await supabase .from('space_members') .select('space_id, role, display_name, id') .eq('user_id', user.id) .in('status', ['current', 'unverified', 'late']) .single() if (!self) return null const { data: threads } = await supabase .from('forum_threads') .select('id, title, category, pinned, locked, comment_count, last_comment_at, created_at, author_id') .eq('space_id', self.space_id) .order('pinned', { ascending: false }) .order('last_comment_at', { ascending: false, nullsFirst: false }) .order('created_at', { ascending: false }) .limit(200) const authorIds = Array.from(new Set((threads ?? []).map(t => t.author_id).filter(Boolean) as string[])) const authorMap: Record = {} if (authorIds.length > 0) { const { data: authors } = await supabase .from('space_members') .select('id, display_name') .in('id', authorIds) for (const a of authors ?? []) authorMap[a.id] = a.display_name ?? 'Member' } return (

Forum

Long-form discussion, announcements, and proposals before they become proposals.

New thread
{threads && threads.length > 0 ? (
{threads.map(t => (
{t.pinned && } {t.locked && } {t.title} {t.category}

{(t.author_id && authorMap[t.author_id]) ?? 'Member'} {' · '} {t.comment_count} {t.comment_count === 1 ? 'reply' : 'replies'} {t.last_comment_at && <> · last activity {new Date(t.last_comment_at).toLocaleString()}}

))}
) : (

No threads yet.

Start the conversation.

Start a thread
)}
) }