import { routerRedux } from 'dva/router';
import * as roleEditService from '../../services/FM/roleEdit';

export default {

  namespace: 'FMRoleEdit',
  state: {
  },

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

    },
  },

  effects: {
    *getRole ({ payload,onComplete }, { call, put }) {
      const ret = yield call(roleEditService.getRole, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getBtnList({ payload,onComplete }, { call, put }) {
      const ret = yield call(roleEditService.getBtnList, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *updateRole ({ payload, onComplete }, { call, put}) {
      const ret = yield call(roleEditService.updateRole, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getPermissionForms ({ payload, onComplete }, { call, put}) {
      const ret = yield call(roleEditService.getPermissionForms, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getWorkstages ({ payload, onComplete }, { call, put}) {
      const ret = yield call(roleEditService.getWorkstages, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
    *getPanels ({ payload, onComplete }, { call, put}) {
      const ret = yield call(roleEditService.getPanels, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
    },
  },

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

};
