import Link from 'next/link';

import SelectAnalysisPackages from '@/components/select-analysis-packages';
import { CaretRightIcon } from '@radix-ui/react-icons';
import { Scale } from 'lucide-react';

import { Button } from '@kit/ui/button';
import { Trans } from '@kit/ui/trans';

import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
import { withI18n } from '~/lib/i18n/with-i18n';

import { MedReportLogo } from '../../components/med-report-logo';
import pathsConfig from '../../config/paths.config';
import ComparePackagesModal from '../home/(user)/_components/compare-packages-modal';
import { loadAnalysisPackages } from '../home/(user)/_lib/server/load-analysis-packages';

export const generateMetadata = async () => {
  const { t } = await createI18nServerInstance();

  return {
    title: t('marketing:pricing'),
  };
};

async function SelectPackagePage() {
  const { analysisPackageElements, analysisPackages, countryCode } = await loadAnalysisPackages();

  return (
    <div className="container mx-auto my-24 flex flex-col items-center space-y-12">
      <MedReportLogo />
      <div className="space-y-3 text-center">
        <h3>
          <Trans i18nKey={'marketing:selectPackage'} />
        </h3>
        <ComparePackagesModal
          analysisPackages={analysisPackages}
          analysisPackageElements={analysisPackageElements}
          triggerElement={
            <Button variant="secondary" className="gap-2">
              <Trans i18nKey={'marketing:comparePackages'} />
              <Scale className="size-4 stroke-[1.5px]" />
            </Button>
          }
        />
      </div>
      <SelectAnalysisPackages analysisPackages={analysisPackages} countryCode={countryCode} />
      <div className="flex justify-center">
        <Link href={pathsConfig.app.home}>
          <Button variant="secondary" className="align-center">
            <Trans i18nKey="marketing:notInterestedInAudit" />{' '}
            <CaretRightIcon className="size-4" />
          </Button>
        </Link>
      </div>
    </div>
  );
}

export default withI18n(SelectPackagePage);
