feature : Connect front to backend #1

Merged
BoxOfPandor merged 25 commits from feat/connect-front-to-backend into main 2026-03-19 14:56:19 +01:00
2 changed files with 17 additions and 5 deletions
Showing only changes of commit bc9d93fe90 - Show all commits

View File

@@ -217,7 +217,7 @@ export default function ForumPage() {
{!loading && !error && (
filteredCategories.length === 0 ? (
<div className="crt-box" style={{ padding: '2rem', textAlign: 'center', color: 'var(--color-text-muted)', fontFamily: 'var(--font-mono)' }}>
No results found for "{search}"
{search.trim() ? `No results found for "${search}"` : 'No forum categories available yet.'}
</div>
) : (
filteredCategories.map((cat) => (

View File

@@ -114,14 +114,26 @@ export const forumApi = {
getCategories: () =>
apiFetch<ForumCategory[]>('/forum/categories'),
getThreads: (params?: { categoryId?: string; page?: number; limit?: number }) => {
getThreads: async (params?: { categoryId?: string; page?: number; limit?: number }) => {
const q = new URLSearchParams();
if (params?.categoryId) q.set('categoryId', params.categoryId);
q.set('page', String(params?.page ?? 1));
q.set('limit', String(params?.limit ?? 100));
return apiFetch<{ data: ForumThread[]; total: number; page: number; pages: number }>(
`/forum/threads?${q}`
);
const result = await apiFetch<{
data?: ForumThread[];
threads?: ForumThread[];
total: number;
page: number;
pages: number;
}>(`/forum/threads?${q}`);
return {
data: result.data ?? result.threads ?? [],
total: result.total,
page: result.page,
pages: result.pages,
};
},
getThread: (id: string) =>