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 { forumIsModerator, canEditPost } from '@/lib/forum-perm' import { ReplyForm } from '@/components/ReplyForm' import { PostActions } from '@/components/PostActions' import { TopicModBar } from '@/components/TopicModBar' 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 isMod = await forumIsModerator(session) const canReply = Boolean(session.username) && (!topic!.locked || isMod) return (

← {t('backToForum')}

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

{isMod && }
{posts.map((post) => (
{post.poster} {post.time && ( {new Date(post.time).toLocaleString(locale)} {post.edited && · {t('editedMark')}} )}
{canEditPost(session, isMod, post.poster_id) && ( )}
))}
{canReply ? ( ) : ( !session.username &&

{t('loginToPost')}

)}
) }