yapi/client/reducer/group/group.js

36 lines
651 B
JavaScript
Raw Normal View History

2017-07-11 16:35:39 +08:00
import {
FETCH_GROUP_LIST,
FETCH_CURR_GROUP
} from '../../constants/action-types';
const initialState = {
2017-07-12 16:38:42 +08:00
groupList: [],
2017-07-11 16:35:39 +08:00
currGroup: 'MFE'
};
export default (state = initialState, action) => {
switch (action.type) {
case FETCH_GROUP_LIST: {
2017-07-14 15:15:59 +08:00
if (!action.payload.data.errcode) {
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;
}
case FETCH_CURR_GROUP: {
if (action.payload.res) {
return {
...state,
2017-07-12 14:18:17 +08:00
currGroup: action.payload.data
2017-07-11 16:35:39 +08:00
};
}
return state;
}
default:
return state;
}
};