/** * FAQ accordion (bare skeleton) — fully driven by the merchant's dashboard * configuration. * * The merchant configures FAQs in the Brainerce dashboard under * Sell → Content → FAQ * * Each FAQ row has a `key` (e.g. 'main', 'shipping', 'returns'). Pass the * pre-fetched payload as `faq`; this component knows nothing about which * key it came from. * * Two render branches: * 1. `faq` has items → accordion of question/answer pairs * 2. `faq` is null OR has no items → friendly empty state with a contact * CTA, so the /faq page never looks broken before the merchant seeds. * * Security: FAQ answers may contain merchant-authored HTML — we sanitize * via `sanitizeHtml` before injecting via dangerouslySetInnerHTML. */ 'use client'; import * as React from 'react'; import { Link } from '@/core/lib/navigation'; import type { Content } from 'brainerce'; import { useTranslations } from '@/core/lib/translations'; import { sanitizeHtml } from '@/core/lib/sanitize'; interface FaqSectionProps { /** Pre-fetched FAQ row. `null` renders the empty-state fallback. */ faq: Content<'FAQ'> | null; } export function FaqSection({ faq }: FaqSectionProps) { const t = useTranslations('content'); const items = faq?.data?.items ?? []; const heading = faq?.name || t('faqTitle'); // Empty state — runs when the merchant hasn't created a FAQ row yet, // or the row exists but contains no items. if (!faq || items.length === 0) { return (

{heading}

{t('faqEmptyTitle')} {t('faqEmptyBody')}

{t('faqContactCta')}
); } return (

{heading}

); }