import * as pdtOrderService from '../../services/WO/pdtOrder';

export default {

  namespace: 'WOPdtOrder',
  state: {
  },

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

    },
  },

  effects: {
    *getPdtOrder ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.getPdtOrder, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },*getPdtOrderProcess ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.getPdtOrderProcess, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },*getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *cancelEmConfirmStatus ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.cancelEmConfirmStatus, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateEMConfirmStatus ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.updateEMConfirmStatus, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *cancelPdtOrder ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.cancelPdtOrder, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getImgFiles ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.getImgFiles, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *savePdtOrderBom ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.savePdtOrderBom, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getPdtOrderById ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.getPdtOrderById, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *completePdtOrder ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.completePdtOrder, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *confirmFeedingComplete ({ payload,onComplete }, { call, put }) {
      const ret = yield call(pdtOrderService.confirmFeedingComplete, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *reworkConfirm ({ payload, onComplete }, { call, put}) {
      const ret = yield call(pdtOrderService.ReworkConfirm, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }
  },

  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    },
  },

};
