"use client";

import React from "react";
import { useTranslation } from "react-i18next";
import Toggle from "@/components/ui/Toggle";
import type { FormikProps } from "formik";
import type { IndividualRegistrationValues } from "./individualRegistrationValues";

/** A field group lifted out of the form of the same family. */
export default function IndividualRealNameToggle({
  values,
  setFieldValue,
}: {
  values: IndividualRegistrationValues;
  setFieldValue: FormikProps<IndividualRegistrationValues>["setFieldValue"];
}) {
  const { t } = useTranslation();

  return (
  <>
    <p className="-mt-2 mb-4 text-sm text-secondary-102">
      {t("COMMON.REAL_NAME_CERTIFICATE_NOTICE")}
    </p>
    <div className="mb-4 flex items-start justify-between gap-4 rounded-2xl bg-[#29246D08] p-4">
      <div>
        <p className="font-bold text-primary-5">
          {t("COMMON.SHOW_REAL_NAME")}
        </p>
        <p className="text-sm text-secondary-102">
          {values.wants_trainer
            ? t("COMMON.SHOW_REAL_NAME_TRAINER_HINT")
            : t("COMMON.SHOW_REAL_NAME_HINT")}
        </p>
      </div>
      <Toggle
        label=""
        ariaLabel={t("COMMON.SHOW_REAL_NAME")}
        checked={values.wants_trainer || values.show_real_name}
        disabled={values.wants_trainer}
        onChange={() =>
          setFieldValue("show_real_name", !values.show_real_name)
        }
      />
    </div>
  </>
  );
}
