import { notFound } from 'next/navigation' import { getTranslations, setRequestLocale } from 'next-intl/server' import { Link } from '@/i18n/navigation' import { getTopic, getPosts } from '@/lib/forum' import { getSession } from '@/lib/session' import { ReplyForm } from '@/components/ReplyForm' export const dynamic = 'force-dynamic' export default async function TopicPage({ params, }: { params: Promise<{ locale: string; topicId: string }> }) { const { locale, topicId } = await params setRequestLocale(locale) const t = await getTranslations('Forum') const id = Number(topicId) const topic = await getTopic(id) if (!topic) notFound() const posts = await getPosts(id) const session = await getSession() const canReply = Boolean(session.username) && !topic!.locked return (

← {t('backToForum')}

{topic!.locked && [{t('locked')}]} {topic!.name}

{posts.map((post) => (
{post.poster} {post.time && ( {new Date(post.time).toLocaleString(locale)} )}
))}
{canReply ? ( ) : ( !session.username &&

{t('loginToPost')}

)}
) }