"use client"; import { FormEvent, useEffect, useRef, useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useAccount } from "@/contexts/AccountContext"; import { FORUM_RINGS } from "@/lib/forumRings"; import { addThread } from "@/lib/forumState"; export default function VoidAggregateSubmitPage() { const router = useRouter(); const { user, hydrated } = useAccount(); const prefilledAuthor = useRef(false); const [topicSlug, setTopicSlug] = useState(FORUM_RINGS[0]!.slug); const [title, setTitle] = useState(""); const [body, setBody] = useState(""); const [author, setAuthor] = useState(""); useEffect(() => { if (!hydrated || !user || prefilledAuthor.current) return; setAuthor(user.displayName); prefilledAuthor.current = true; }, [hydrated, user]); useEffect(() => { if (typeof window === "undefined") return; const q = new URLSearchParams(window.location.search).get("ring"); if (q && FORUM_RINGS.some((r) => r.slug === q)) setTopicSlug(q); }, []); const onSubmit = (e: FormEvent) => { e.preventDefault(); if (!title.trim() || !body.trim()) return; const t = addThread({ topicSlug, title, body, author, }); router.push(`/forum/post/${t.id}`); }; return (
Pick a ring, write a title, drop your text. Unsigned posts are untrusted.