diff --git a/nest-front/src/pages/public/ForumPage.tsx b/nest-front/src/pages/public/ForumPage.tsx index 530f5d2..b3171ba 100644 --- a/nest-front/src/pages/public/ForumPage.tsx +++ b/nest-front/src/pages/public/ForumPage.tsx @@ -217,7 +217,7 @@ export default function ForumPage() { {!loading && !error && ( filteredCategories.length === 0 ? (
- No results found for "{search}" + {search.trim() ? `No results found for "${search}"` : 'No forum categories available yet.'}
) : ( filteredCategories.map((cat) => ( diff --git a/nest-front/src/utils/api.ts b/nest-front/src/utils/api.ts index deb4a1a..6fdbf68 100644 --- a/nest-front/src/utils/api.ts +++ b/nest-front/src/utils/api.ts @@ -114,14 +114,26 @@ export const forumApi = { getCategories: () => apiFetch('/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) =>