import { Link } from 'react-router-dom' import { useTranslation } from 'react-i18next' export default function PortalTopicRow({ thread, forumName, forumId, showForum = true }) { const { t } = useTranslation() const authorName = thread.user_name || t('thread.anonymous') const lastAuthorName = thread.last_post_user_name || authorName const lastPostAnchor = thread.last_post_id ? `#post-${thread.last_post_id}` : '' const formatDateTime = (value) => { if (!value) return '—' const date = new Date(value) if (Number.isNaN(date.getTime())) return '—' const day = String(date.getDate()).padStart(2, '0') const month = String(date.getMonth() + 1).padStart(2, '0') const year = String(date.getFullYear()) const hours = String(date.getHours()).padStart(2, '0') const minutes = String(date.getMinutes()).padStart(2, '0') const seconds = String(date.getSeconds()).padStart(2, '0') return `${day}.${month}.${year} ${hours}:${minutes}:${seconds}` } return (
{thread.title}
{t('portal.posted_by')} {thread.user_id ? ( {authorName} ) : ( {authorName} )} » {formatDateTime(thread.created_at)}
{showForum && (
{t('portal.forum_label')} {forumId ? ( {forumName} ) : ( forumName )}
)}
{thread.posts_count ?? 0}
{thread.views_count ?? 0}
{t('thread.by')}{' '} {thread.last_post_user_id ? ( {lastAuthorName} ) : ( {lastAuthorName} )}