import { getTranslation } from "@turbostarter/i18n/server";
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@turbostarter/ui-web/accordion";
import { buttonVariants } from "@turbostarter/ui-web/button";
import { Icons } from "@turbostarter/ui-web/icons";

import { pathsConfig } from "~/config/paths";
import { TurboLink } from "~/modules/common/turbo-link";
import {
  Section,
  SectionHeader,
  SectionBadge,
  SectionTitle,
  SectionDescription,
} from "~/modules/marketing/layout/section";

const questions = [
  {
    question: "faq.question.whatReviewsAnalyzed.question",
    answer: "faq.question.whatReviewsAnalyzed.answer",
  },
  {
    question: "faq.question.howScoringWorks.question",
    answer: "faq.question.howScoringWorks.answer",
  },
  {
    question: "faq.question.deliveryTime.question",
    answer: "faq.question.deliveryTime.answer",
  },
  {
    question: "faq.question.whatBusinessTypes.question",
    answer: "faq.question.whatBusinessTypes.answer",
  },
  {
    question: "faq.question.dataPrivacy.question",
    answer: "faq.question.dataPrivacy.answer",
  },
  {
    question: "faq.question.howManyReviews.question",
    answer: "faq.question.howManyReviews.answer",
  },
  {
    question: "faq.question.reportContents.question",
    answer: "faq.question.reportContents.answer",
  },
] as const;

export const Faq = async () => {
  const { t } = await getTranslation({ ns: "marketing" });

  return (
    <Section id="faq" className="lg:flex-row lg:items-start">
      <SectionHeader className="grow basis-0 lg:items-start">
        <SectionBadge>{t("faq.label")}</SectionBadge>
        <SectionTitle className="lg:text-left">{t("faq.title")}</SectionTitle>
        <SectionDescription className="lg:text-left">
          {t("faq.description")}
        </SectionDescription>

        <TurboLink
          href={pathsConfig.marketing.contact}
          className={buttonVariants({
            variant: "outline",
          })}
        >
          {t("faq.cta")}
          <Icons.ArrowRight className="ml-1 size-4" />
        </TurboLink>
      </SectionHeader>

      <Accordion type="multiple" className="grow basis-0">
        {questions.map((question) => (
          <AccordionItem key={question.question} value={question.question}>
            <AccordionTrigger className="text-base">
              {t(question.question)}
            </AccordionTrigger>
            <AccordionContent className="text-base">
              {t(question.answer)}
            </AccordionContent>
          </AccordionItem>
        ))}
      </Accordion>
    </Section>
  );
};
