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

export const getInitialValues = (objectToEdit: any | null = null): any => {
  console.log(objectToEdit,"objectToEdit");
  return {
    whatsApp: "",
    subject: "",
    message: "",
    id:null,
  };
};


export const getValidationSchema = (editMode: boolean = false): Yup.Schema<any> => {
  // Validate input
  return Yup.object().shape({
    whatsApp: Yup.string().required('Required'),
    subject: Yup.string().required('Required'),
    message: Yup.string().required('Required'),
    id: Yup.string().required('Required'),

  });
};



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
}