"use client";

import { useTranslation } from "react-i18next";
import ModalInput from "@/components/ui/ModalInput";
import { ModalPhoneInput } from "@/components/ui/PhoneInput";
import CountryCodeSelect, {
  FIELD_LABEL_CLASS,
} from "./registerVolunteerParts";
import type { FormikProps } from "formik";
import type { RegisterVolunteerValues } from "./registerVolunteerValues";

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

  return (
  <div className="grid grid-cols-2 mobilescreen:grid-cols-1 mobilescreen:gap-[0px] gap-[100px]">
    <div>
      <p className={FIELD_LABEL_CLASS}>
        {t("COMMON.EMERGENCY_CONTACT_PHONE")}
      </p>
      <div className="flex gap-2">
        <div>
          <CountryCodeSelect
            name="emergency_contact_country_code"
            className="w-full"
            onChange={(value: string) =>
              setFieldValue(
                "emergency_contact_country_code",
                value
              )
            }
          />
        </div>
        <ModalPhoneInput
          name="emergency_contact_phone"
          placeholder={t("COMMON.EMERGENCY_CONTACT_PHONE")}
          countryCode={values.emergency_contact_country_code}
        />
      </div>
    </div>
    <div>
      <p className={FIELD_LABEL_CLASS}>
        {t("COMMON.EMERGENCY_CONTACT_CIVIL_ID")}
      </p>
      <ModalInput
        name="emergency_contact_civil_id"
        type="text"
        placeholder={t("COMMON.EMERGENCY_CONTACT_CIVIL_ID")}
        maxLength={12}
        digitsOnly
      />
    </div>
  </div>
  );
}
