"use client"; import Link from "next/link"; import { formatRingLabel } from "@/lib/forumRings"; import { displayScore, isPinnedThread, isReadOnlyThread, type ForumThread } from "@/lib/forumState"; import { ThreadVoteColumn } from "@/components/forum/ThreadVoteColumn"; export function ForumPostCard({ thread, onVoteChange, }: { thread: ForumThread; /** Fire when vote changes so list meta (score) re-renders from localStorage */ onVoteChange?: () => void; }) { const pinned = isPinnedThread(thread); const locked = isReadOnlyThread(thread.id); const score = displayScore(thread); return (
e.stopPropagation()} className="shrink-0">
{pinned ? ( Pinned ) : null} {locked ? ( Staff ) : null}

{formatRingLabel(thread.topicSlug)} · {thread.author || "Anonymous"} · {formatAgo(thread.ts)} · {score} pts

{thread.title}

{thread.body}

{thread.replies.length} comments
); } function formatAgo(ts: number): string { const s = Math.floor((Date.now() - ts) / 1000); if (s < 60) return `${s}s ago`; const m = Math.floor(s / 60); if (m < 60) return `${m}m ago`; const h = Math.floor(m / 60); if (h < 48) return `${h}h ago`; const d = Math.floor(h / 24); return `${d}d ago`; }