"use client"; import Link from "next/link"; import { useState, useEffect } from "react"; import { useAccount } from "@/contexts/AccountContext"; import { loadForum, addThread, displayScore, setVoteForThread, getVoteForThread, type ForumThread, } from "@/lib/forumState"; const CATEGORIES = ["All", "Security", "Market", "OPSEC", "Tech", "General"]; export default function ForumBoard() { const { user } = useAccount(); const [threads, setThreads] = useState([]); const [newPost, setNewPost] = useState(""); const [selectedCat, setSelectedCat] = useState("All"); const [voteBump, setVoteBump] = useState(0); const [posting, setPosting] = useState(false); useEffect(() => { setThreads(loadForum().slice(0, 8)); }, []); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!newPost.trim() || posting) return; setPosting(true); const thread = addThread({ title: newPost.slice(0, 80), body: newPost, author: user?.username ?? "anon", topicSlug: "general", category: "General", replies: [], }); setThreads([thread, ...threads].slice(0, 8)); setNewPost(""); setPosting(false); }; const handleVote = (id: string, delta: 1 | -1) => { const existing = getVoteForThread(id); const next = existing === delta ? 0 : delta; setVoteForThread(id, next as 1 | -1 | 0); setVoteBump((v) => v + 1); }; const visible = selectedCat === "All" ? threads : threads.filter((t) => t.category === selectedCat || t.topicSlug === selectedCat.toLowerCase()); return (

VOID AGGREGATE

{threads.length} threads shown · full board at{" "} /forum

{/* Category filter */}
{CATEGORIES.map((cat) => ( ))}
{/* Quick post form */}