import * as Yup from "yup";

import dayjs from "dayjs";

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

  return {
    id: objectToEdit?.id ?? null,
    name: objectToEdit?.name ?? 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,
    status: objectToEdit?.status === "active" ? true : false,
  };
};

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