import { routerRedux } from 'dva/router';
import * as showInventoryService from '../../services/WH/showInventory';

export default {

  namespace: 'WHShowInventory',
  state: {
  },

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

    },
  },

  effects: {
    *getInventoryList ({ payload,onComplete }, { call, put }) {
      const ret = yield call(showInventoryService.getInventoryList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getInventoryOccupyList ({ payload,onComplete }, { call, put }) {
      const ret = yield call(showInventoryService.getInventoryOccupyList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getInventoryUsedByProduct ({ payload,onComplete }, { call, put }) {
      const ret = yield call(showInventoryService.getInventoryUsedByProduct, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    }
  },

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

};
