import Validation from "@helpers/validation"
import Formating from "@helpers/formating"

const validation = new Validation()
const formating = new Formating()

class ServiceOfCron {
  constructor(api, store) {
    this.api = api
    this.store = store
  }

  /**
   * @param {Object} paramsFields
   * @param {Object} params
   * @returns {Promise<Object>}
   */
  setCronFields (paramsFields, params) {
    paramsFields[params.key] = params.value
    if (params.key === 'dtStart' || params.key === 'dtFinish') {
      paramsFields = {...paramsFields, [params.key]: formating.getDate(params.key, params.value)}
    }
    if (params.key === 'imei') {
      return {paramsFields, errorKey: 'errorImei', errorValue: validation.imei(params.value)}
    }
    if (params.key === 'packNumber') {
      return {paramsFields, errorKey: 'errorPackNumber', errorValue: validation.packNumber(params.value)}
    }
    return {paramsFields}
  }

}

export default ServiceOfCron