feat: integrate settings API to manage forum and bug reporting availability
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { forumApi } from '../../utils/api';
|
||||
import { forumApi, settingsApi } from '../../utils/api';
|
||||
import { timeAgo } from '../../utils/format';
|
||||
import type { ForumCategory, ForumThread } from '../../types';
|
||||
|
||||
@@ -132,17 +132,20 @@ export default function ForumPage() {
|
||||
const [threads, setThreads] = useState<ForumThread[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState('');
|
||||
const [forumEnabled, setForumEnabled] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
|
||||
Promise.all([
|
||||
settingsApi.get(),
|
||||
forumApi.getCategories(),
|
||||
forumApi.getThreads({ limit: 200 }),
|
||||
])
|
||||
.then(([cats, threadRes]) => {
|
||||
.then(([settings, cats, threadRes]) => {
|
||||
if (cancelled) return;
|
||||
setForumEnabled(settings.forumEnabled);
|
||||
setCategories(cats);
|
||||
setThreads(threadRes.data);
|
||||
})
|
||||
@@ -166,6 +169,20 @@ export default function ForumPage() {
|
||||
);
|
||||
}, [search, categories, threads]);
|
||||
|
||||
if (!loading && !forumEnabled) {
|
||||
return (
|
||||
<div style={{ maxWidth: '960px', margin: '0 auto', padding: '4rem 1.5rem', textAlign: 'center' }}>
|
||||
<div className="section-label">Community</div>
|
||||
<h1 style={{ fontFamily: 'var(--font-heading)', color: 'var(--color-red)', fontSize: 'clamp(2rem, 5vw, 3rem)', marginTop: '0.5rem' }}>
|
||||
FORUM UNAVAILABLE
|
||||
</h1>
|
||||
<p style={{ color: 'var(--color-text-muted)', fontSize: '0.8rem', marginTop: '1rem', fontFamily: 'var(--font-mono)' }}>
|
||||
The forum has been temporarily disabled by an administrator.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ maxWidth: '960px', margin: '0 auto', padding: '4rem 1.5rem' }}>
|
||||
{/* Header */}
|
||||
|
||||
Reference in New Issue
Block a user