import { routerRedux } from 'dva/router';
import * as mrpService from '../../services/SO/mrp';

export default {

  namespace: 'SOMrp',
  state: {
  },

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

    },
  },

  effects: {
    *getMrpData ({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpService.getMrpData, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *saveMrpData({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpService.saveMrpData, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getMrpEmProposals({ payload,onComplete }, { call, put }) {
      const ret = yield call(mrpService.getMrpEmProposals, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

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

};
