import { routerRedux } from 'dva/router';
import * as mrpEditService from '../../services/SO/mrpEdit';

export default {

  namespace: 'SOMrpEdit',
  state: {
  },

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

    },
  },

  effects: {
    *getMrp ({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpEditService.getMrp, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpEditService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateMrp ({ payload, onComplete }, { call, put}) {
      const ret = yield call(mrpEditService.updateMrp, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }, *cancelMrp ({ payload, onComplete }, { call, put}) {
      const ret = yield call(mrpEditService.cancelMrp, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }, *mrpConfirm ({ payload, onComplete }, { call, put}) {
      const ret = yield call(mrpEditService.mrpConfirm, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *mrpConfirmWorkByEmOrder ({ payload, onComplete }, { call, put}) {
      const ret = yield call(mrpEditService.mrpConfirmWorkByEmOrder, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

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

};
