Unify portal thread rows and add summary API

This commit is contained in:
Micha
2026-01-16 02:44:04 +01:00
parent f9de433545
commit 24c16ed0dd
12 changed files with 380 additions and 188 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
import { Button, Badge, Card, Col, Container, Form, Modal, Row } from 'react-bootstrap'
import { Link, useParams } from 'react-router-dom'
import { createThread, getForum, listForumsByParent, listThreadsByForum } from '../api/client'
import PortalTopicRow from '../components/PortalTopicRow'
import { useAuth } from '../context/AuthContext'
import { useTranslation } from 'react-i18next'
@@ -172,71 +173,24 @@ export default function ForumView() {
</div>
</div>
{!token && <p className="bb-muted mb-3">{t('forum.login_hint')}</p>}
<div className="bb-topic-table">
<div className="bb-topic-header">
<div className="bb-topic-cell bb-topic-cell--title">{t('forum.threads')}</div>
<div className="bb-topic-cell bb-topic-cell--replies">{t('thread.replies')}</div>
<div className="bb-topic-cell bb-topic-cell--views">{t('thread.views')}</div>
<div className="bb-topic-cell bb-topic-cell--last">{t('thread.last_post')}</div>
<div className="bb-portal-topic-table">
<div className="bb-portal-topic-header">
<span>{t('portal.topic')}</span>
<span>{t('thread.replies')}</span>
<span>{t('thread.views')}</span>
<span>{t('thread.last_post')}</span>
</div>
{threads.length === 0 && (
<div className="bb-topic-empty">{t('forum.empty_threads')}</div>
)}
{threads.map((thread) => (
<div className="bb-topic-row" key={thread.id}>
<div className="bb-topic-cell bb-topic-cell--title">
<div className="bb-topic-title">
<span className="bb-topic-icon" aria-hidden="true">
<i className="bi bi-chat-left" />
</span>
<div className="bb-topic-text">
<Link to={`/thread/${thread.id}`}>{thread.title}</Link>
<div className="bb-topic-meta">
<i className="bi bi-paperclip" aria-hidden="true" />
<span>{t('thread.by')}</span>
<span className="bb-topic-author">
{thread.user_name || t('thread.anonymous')}
</span>
{thread.created_at && (
<span className="bb-topic-date">
{thread.created_at.slice(0, 10)}
</span>
)}
</div>
</div>
</div>
</div>
<div className="bb-topic-cell bb-topic-cell--replies">
{thread.posts_count ?? 0}
</div>
<div className="bb-topic-cell bb-topic-cell--views">
{thread.views_count ?? 0}
</div>
<div className="bb-topic-cell bb-topic-cell--last">
<div className="bb-topic-last">
<span className="bb-topic-last-by">
{t('thread.by')}{' '}
{thread.last_post_user_id ? (
<Link
to={`/profile/${thread.last_post_user_id}`}
className="bb-topic-author"
>
{thread.last_post_user_name || t('thread.anonymous')}
</Link>
) : (
<span className="bb-topic-author">
{thread.last_post_user_name || t('thread.anonymous')}
</span>
)}
</span>
{thread.last_post_at && (
<span className="bb-topic-date">
{thread.last_post_at.slice(0, 10)}
</span>
)}
</div>
</div>
</div>
<PortalTopicRow
key={thread.id}
thread={thread}
forumName={forum?.name || t('portal.unknown_forum')}
forumId={forum?.id}
showForum={false}
/>
))}
</div>
</>