import { Field, FieldDescription, FieldGroup, FieldLegend, FieldSet } from '@repo/shadcn-ui/components';

import { SelectField } from "@repo/rdx-ui/components";
import { useFormContext } from "react-hook-form";
import { CURRENCY_OPTIONS, LANGUAGE_OPTIONS } from "../../constants";
import { useTranslation } from "../../i18n";
import { CustomerFormData } from "../../schemas";

export const CustomerAdditionalConfigFields = () => {
  const { t } = useTranslation();
  const { control } = useFormContext<CustomerFormData>();

  return (
    <FieldSet>
      <FieldLegend>{t("form_groups.preferences.title")}</FieldLegend>
      <FieldDescription>{t("form_groups.preferences.description")}</FieldDescription>
      <FieldGroup className='grid grid-cols-1 gap-x-6 lg:grid-cols-4'>
        <Field className='lg:col-span-2'>
          <SelectField
            control={control}
            name='language_code'
            required
            label={t("form_fields.language_code.label")}
            placeholder={t("form_fields.language_code.placeholder")}
            description={t("form_fields.language_code.description")}
            items={[...LANGUAGE_OPTIONS]}
          />
        </Field>
        <Field className='lg:col-span-2'>
          <SelectField
            className='lg:col-span-2'
            control={control}
            name='currency_code'
            required
            label={t("form_fields.currency_code.label")}
            placeholder={t("form_fields.currency_code.placeholder")}
            description={t("form_fields.currency_code.description")}
            items={[...CURRENCY_OPTIONS]}
          />
        </Field>
      </FieldGroup>
    </FieldSet>
  );
};
