import * as yup from "yup";

import useAppForm from "../hooks/useAppForm";

const storeSchema = () => {
  return yup.object({
    countryId: yup.number(),
    state: yup.string(),
  });
};

const STORE_FORM_ID = "stores";

export default function useStores() {
  const { handleSubmit, reset, setValue } = useAppForm({
    schema: storeSchema(),
    defaultValues: {
      countryId: null,
      store: "",
    },
    id: STORE_FORM_ID,
  });
  return {
    storeFormId: STORE_FORM_ID,
    handleSubmit,
    resetStoreForm: reset,
    setFormValue: setValue,
  };
}
