yapi/client/reducer/group/group.js

36 lines
683 B
JavaScript
Raw Normal View History

2017-07-11 16:35:39 +08:00
import {
FETCH_GROUP_LIST,
2017-07-17 10:17:29 +08:00
SET_CURR_GROUP
2017-07-11 16:35:39 +08:00
} from '../../constants/action-types';
2017-07-19 15:32:51 +08:00
import { message } from 'antd'
2017-07-11 16:35:39 +08:00
const initialState = {
2017-07-12 16:38:42 +08:00
groupList: [],
2017-07-17 19:27:20 +08:00
currGroup: { group_name: '' }
2017-07-11 16:35:39 +08:00
};
export default (state = initialState, action) => {
switch (action.type) {
case FETCH_GROUP_LIST: {
2017-07-19 15:32:51 +08:00
if (action.payload.data.errcode) {
message.error(action.payload.data.errmsg);
} else {
2017-07-11 16:35:39 +08:00
return {
...state,
2017-07-14 15:15:59 +08:00
groupList: action.payload.data.data
2017-07-11 16:35:39 +08:00
};
}
return state;
}
2017-07-17 10:17:29 +08:00
case SET_CURR_GROUP: {
return {
...state,
currGroup: action.payload
};
2017-07-11 16:35:39 +08:00
}
default:
return state;
}
};