import { getMemberToken, getApiBaseUrl } from '../../_lib/api'; import { KnowledgeItem } from './KnowledgeItem'; import { KnowledgeSearch } from './KnowledgeSearch'; import Link from 'next/link'; interface Board { id: string; name: string; description: string | null; items: Array<{ id: string; question: string; answer: string; tags: string[] }>; } async function fetchKnowledge(token: string, q?: string): Promise { const params = new URLSearchParams(); if (q) params.set('q', q); const res = await fetch(`${getApiBaseUrl()}/my/knowledge${params.toString() ? `?${params.toString()}` : ''}`, { headers: { Authorization: `Bearer ${token}` }, cache: 'no-store', }).catch(() => null); if (!res || !res.ok) return []; return (await res.json()) as Board[]; } export default async function KnowledgePage({ searchParams, }: { searchParams: Promise<{ q?: string }>; }) { const token = await getMemberToken(); if (!token) return null; const { q } = await searchParams; const boards = await fetchKnowledge(token, q); return (

Knowledge base

← Dashboard
{boards.length === 0 ? (

{q ? 'No matching articles.' : 'No knowledge articles yet.'}

{!q &&

Your chapter admin will publish FAQs and guides here.

}
) : (
{boards.map((b) => (

{b.name}

{b.description &&

{b.description}

}
{b.items.map((item) => ( ))}
))}
)}
); }