import { getTranslations } from "next-intl/server"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { ContentCard } from "@/components/public/ui"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import { postThread } from "@/actions/social"; export const dynamic = "force-dynamic"; export default async function NewThreadPage({ params, }: { params: Promise<{ id: string }>; }) { const t = await getTranslations("pages.guildForumNew"); const { id } = await params; const guildId = Number(id); if (!Number.isInteger(guildId) || guildId <= 0) notFound(); // Auth gate: only logged-in users may open a thread. const session = await auth(); if (!session?.user?.id) redirect("/login"); // Guild header (read-only). A DB hiccup degrades to notFound rather than 500. let guild: { id: number; name: string } | null = null; try { guild = await prisma.guilds.findUnique({ where: { id: guildId }, select: { id: true, name: true }, }); } catch { guild = null; } if (!guild) notFound(); return (

{t("backToForum")}

{/* Guild target drives the write; the author is taken from the session inside the action, never from this form. */}