import { useRef } from "react";

import { AddressSchema } from "../constants/address.schema";
import useAppForm from "../hooks/useAppForm";

export default function useAddresses() {
  const formId = useRef("billingAddress");

  const { handleSubmit, reset, setValue } = useAppForm({
    schema: AddressSchema(),
    defaultValues: {
      firstName: "",
      lastName: "",
      address: "",
      type: "",
      countryId: null,
      state: "",
      city: "",
      postalCode: "",
      phone: "",
      zipCodeRegex: "",
      zipCodeExample: [],
      minPhoneLength: "5",
    },
    id: formId.current,
  });
  return { formId, handleSubmit, resetForm: reset, setFormValue: setValue };
}
