import { useRef } from "react";

import { AddressShippingSchema } from "../constants/address-shipping.schema";
import useAppForm from "../hooks/useAppForm";

export default function useShippingAddresses() {
  const formId = useRef("shippingAddress");

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