import * as Yup from "yup";

import dayjs from "dayjs";

export const getInitialValues = (objectToEdit: any): any => {
  console.log(objectToEdit, "objectToEdit");

  return {
    id: objectToEdit?.id ?? null,
    starting_date: objectToEdit?.starting_date
      ? dayjs(objectToEdit?.starting_date, "YYYY/MM/DD")
      : null ?? null,
    ending_date: objectToEdit?.ending_date
      ? dayjs(objectToEdit?.ending_date, "YYYY/MM/DD")
      : null ?? null,
    term_type: objectToEdit?.term_type ?? null,
    description: objectToEdit?.description ?? null,
  };
};

export const getValidationSchema = () => {
  // validate input
  return Yup.object().shape({
    starting_date: Yup.string().required("validation.required"),
    ending_date: Yup.string().required("validation.required"),
    term_type: Yup.string().required("validation.required"),
    description: Yup.string().required("validation.required"),
  });
};
