
import * as Yup from "yup";
import { buildFormData } from "../../../api/helper/buildFormData";
import * as dayjs from 'dayjs'


export const getInitialValues = (objectToEdit: any | null = null): any => {
  // console.log(objectToEdit,"objectToEdit");
  return {
    id: objectToEdit?.id ?? 0,
    state:objectToEdit?.state ?? "",
    admin_note: objectToEdit?.admin_note ?? '',
        //@ts-ignore
    deliviration_estimated_time: dayjs(objectToEdit?.deliviration_estimated_time,"YYYY-MM-DD") ??"",
    delivery_link:objectToEdit?.delivery_link ??"",
   
  }; 
};


export const getValidationSchema = (editMode: boolean = false): Yup.Schema<any> => {
  // Validate input
  return Yup.object().shape({
    
  });
};



export const getDataToSend = (values: any): FormData => {
  const data = { ...values };
  
  
  const formData = new FormData();
  buildFormData(formData, data);
  return formData;
};

export const ChangeDataToPrint = (data:any)=>{

  let new_array = data
  for(let i =0 ; i<data.length ; i++){
    new_array[i]['status'] =!data[i]['deleted_at'] ?'available':'unavailable'
    delete new_array[i]['deleted_at']
  }
  return new_array
}