/**
 * FAQ page — fully driven by the merchant's dashboard configuration.
 *
 * The merchant configures FAQs in the Brainerce dashboard under
 *   Sell → Content → FAQ
 *
 * This page fetches the merchant's *primary* FAQ (key='main'). For topical
 * FAQs (e.g. /faq/shipping), copy this route to `app/faq/[topic]/page.tsx`
 * and pass `params.topic` to `client.content.faq.get(topic, locale)`.
 */
import * as React from 'react';
import type { Metadata } from 'next';

import { getServerClient } from '@/core/lib/brainerce.server';
import { FaqSection } from '@/ui/layout/faq-section';
<% if (i18nEnabled) { %>
type PageProps = {
  params: Promise<{ locale: string }>;
};

export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
  const { locale } = await params;
  const faq = await (await getServerClient(locale)).content.faq.get('main', locale).catch(() => null);
  return {
    title: faq?.name ?? 'FAQ',
  };
}

export default async function FaqPage({ params }: PageProps) {
  const { locale } = await params;
  const faq = await (await getServerClient(locale)).content.faq.get('main', locale).catch(() => null);
  return <FaqSection faq={faq} />;
}
<% } else { %>
export async function generateMetadata(): Promise<Metadata> {
  const faq = await (await getServerClient()).content.faq.get('main').catch(() => null);
  return {
    title: faq?.name ?? 'FAQ',
  };
}

export default async function FaqPage() {
  const faq = await (await getServerClient()).content.faq.get('main').catch(() => null);
  return <FaqSection faq={faq} />;
}
<% } %>
