/* eslint-disable @typescript-eslint/no-explicit-any */
// components/AddressFields.tsx
import React from "react";
import SelectBox from "@/components/elements/SelectBox";

interface IProvince {
  id: string | number;
  name: string;
}

interface ICity {
  id: string | number;
  name: string;
}

interface AddressFieldsProps {
  formik: any;
  provinces: IProvince[] | null;
  cities: ICity[] | null;
  onProvinceChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
}

const AddressFields: React.FC<AddressFieldsProps> = ({
  formik,
  provinces,
  cities,
  onProvinceChange,
}) => {
  return (
    <>
      <SelectBox
        className="mt-2 max-w-full"
        value={formik.values.stateId}
        onChange={onProvinceChange}
      >
        <option disabled value="">
          استان
        </option>
        {provinces?.map((item: IProvince) => (
          <option key={item.id} value={item.id}>
            {item.name}
          </option>
        ))}
      </SelectBox>
      <SelectBox
        className="mt-2 max-w-full"
        value={formik.values.cityId}
        onChange={(e) => formik.setFieldValue("cityId", e.target.value)}
      >
        <option disabled value="">
          شهر
        </option>
        {cities?.map((city: ICity) => (
          <option key={city.id} value={city.id}>
            {city.name}
          </option>
        ))}
      </SelectBox>
      <input
        type="text"
        name="neighbourhood"
        placeholder="محله"
        className="border mt-2 w-full p-2 rounded-2xl border-border-primary-light dark:border-border-primary-dark bg-secondary-light dark:bg-secondary-dark font-medium max-w-full"
        value={formik.values.neighbourhood}
        onChange={formik.handleChange}
        onBlur={formik.handleBlur}
      />
      <textarea
        name="address"
        placeholder="آدرس"
        className="border mt-2 w-full p-3 rounded-2xl border-border-primary-light dark:border-border-primary-dark bg-secondary-light dark:bg-secondary-dark font-medium max-w-full"
        value={formik.values.address}
        onChange={formik.handleChange}
        onBlur={formik.handleBlur}
      ></textarea>
    </>
  );
};

export default AddressFields;
