import { routerRedux } from 'dva/router';
import * as roleGroupEditService from '../../services/FM/roleGroupEdit';

export default {

  namespace: 'FMRoleGroupEdit',
  state: {
  },

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

    },
  },

  effects: {
    *getRoleGroup ({ payload,onComplete }, { call, put }) {
      const ret = yield call(roleGroupEditService.getRoleGroup, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(roleGroupEditService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateRoleGroup ({ payload, onComplete }, { call, put}) {
      const ret = yield call(roleGroupEditService.updateRoleGroup, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

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

};
