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-14 15:15:59 +08:00
|
|
|
import axios from 'axios';
|
2017-07-11 16:35:39 +08:00
|
|
|
|
|
|
|
export function fetchGroupList() {
|
|
|
|
return {
|
|
|
|
type: FETCH_GROUP_LIST,
|
2017-07-14 15:15:59 +08:00
|
|
|
payload: axios.get('/group/list')
|
2017-07-11 16:35:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 10:17:29 +08:00
|
|
|
export function setCurrGroup(group) {
|
2017-07-11 16:35:39 +08:00
|
|
|
return {
|
2017-07-17 10:17:29 +08:00
|
|
|
type: SET_CURR_GROUP,
|
|
|
|
payload: group
|
2017-07-11 16:35:39 +08:00
|
|
|
}
|
|
|
|
}
|
2017-07-12 15:41:11 +08:00
|
|
|
|
|
|
|
export function addGroup(groupName) {
|
|
|
|
return function(dispatch, getState) {
|
|
|
|
const group = getState().group;
|
|
|
|
const groupList = group.groupList || [];
|
2017-07-14 15:15:59 +08:00
|
|
|
const newGroupList = groupList.concat([{ group_name: groupName + groupList.length }]);
|
2017-07-12 15:41:11 +08:00
|
|
|
dispatch({
|
|
|
|
type: FETCH_GROUP_LIST,
|
2017-07-14 15:15:59 +08:00
|
|
|
payload: { data: {
|
2017-07-12 15:41:11 +08:00
|
|
|
data: newGroupList,
|
2017-07-14 15:15:59 +08:00
|
|
|
errcode: 0
|
|
|
|
}}
|
2017-07-12 15:41:11 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|