import * as Yup from "yup";
import dayjs from "dayjs";

export const getInitialValues = (objectToEdit: any): any => {
  // console.log(objectToEdit,"objectToEdit");
  return {
    id: objectToEdit?.id ?? null,
    registration_record_id:
      objectToEdit?.registration_record?.id ??
      objectToEdit?.registration_record_id ??
      null,
    type: objectToEdit?.type ?? null,
    content: objectToEdit?.content ?? null,
    date: objectToEdit?.date
      ? dayjs(objectToEdit?.date, "YYYY/MM/DD")
      : dayjs(Date()),
    attachments: objectToEdit?.attachments ?? null,
  };
};

export const getValidationSchema = () => {
  // validate input
  return Yup.object().shape({
    registration_record_id: Yup.string().required("validation.required"),
    type: Yup.string().required("validation.required"),
    content: Yup.string().required("validation.required"),
    date: Yup.string().required("validation.required"),
  });
};
