import * as engineeringPlanEditService from '../../services/EM/engineeringPlanEdit'

export default {
  namespace: 'EMengineeringPlanEdit',
  state: {

  },
  subscriptions: {
    setup ({ dispatch, history }) {  // eslint-disable-line

    },
  },
  effects: {
    *getPdtOrder ({ payload, onComplete }, { call, put }) {
      const ret = yield call(engineeringPlanEditService.getPdtOrder, payload)
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getPdtOrderProcess ({ payload, onComplete }, { call, put }) {
      const ret = yield call(engineeringPlanEditService.getPdtOrderProcess, payload)
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList ({ payload, onComplete }, { call, put }) {
      const ret = yield call(engineeringPlanEditService.getBtnList, payload)
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateEMConfirmStatus ({ payload, onComplete }, { call, put }) {
      const ret = yield call(engineeringPlanEditService.updateEMConfirmStatus, payload)
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },
  reducers: {
    save (state, action) {
      return { ...state, ...action.payload }
    },
  },
}
