import { routerRedux } from 'dva/router';
import * as userGroupEditService from '../../services/FM/userGroupEdit';

export default {

  namespace: 'FMUserGroupEdit',
  state: {
  },

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

    },
  },

  effects: {
    *getUserGroup ({ payload,onComplete }, { call, put }) {
      const ret = yield call(userGroupEditService.getUserGroup, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(userGroupEditService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateUserGroup ({ payload, onComplete }, { call, put}) {
      const ret = yield call(userGroupEditService.updateUserGroup, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

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

};
