refactor: connect frontend to backend by integrating SettingsContext and updating route handling for forum and bug reporting features

This commit is contained in:
Thibault Pouch
2026-03-17 16:44:06 +01:00
parent a46dfde6d2
commit 792816c6c8
4 changed files with 48 additions and 70 deletions

View File

@@ -1,6 +1,6 @@
import { useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { forumApi, settingsApi } from '../../utils/api';
import { forumApi } from '../../utils/api';
import { timeAgo } from '../../utils/format';
import type { ForumCategory, ForumThread } from '../../types';
@@ -132,20 +132,17 @@ 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(([settings, cats, threadRes]) => {
.then(([cats, threadRes]) => {
if (cancelled) return;
setForumEnabled(settings.forumEnabled);
setCategories(cats);
setThreads(threadRes.data);
})
@@ -169,20 +166,6 @@ 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 */}