fix: js path

This commit is contained in:
suxiaoxin 2017-07-14 15:16:27 +08:00
commit 74eaf2c308
3 changed files with 15 additions and 13 deletions

View File

@ -2,17 +2,19 @@ import {
FETCH_GROUP_LIST,
FETCH_CURR_GROUP
} from '../constants/action-types';
import axios from 'axios';
export function fetchGroupList() {
return {
type: FETCH_GROUP_LIST,
// payload 可以返回 Promise异步请求使用 axios 即可
payload: new Promise((resolve) => {
resolve({
data: ['Hotel', 'Vacation', 'Flight', 'Pay'],
res: true
})
})
payload: axios.get('/group/list')
// payload: new Promise((resolve) => {
// resolve({
// data: ['Hotel', 'Vacation', 'Flight', 'Pay'],
// res: true
// })
// })
}
}
@ -29,13 +31,13 @@ export function addGroup(groupName) {
return function(dispatch, getState) {
const group = getState().group;
const groupList = group.groupList || [];
const newGroupList = groupList.concat([groupName + groupList.length]);
const newGroupList = groupList.concat([{ group_name: groupName + groupList.length }]);
dispatch({
type: FETCH_GROUP_LIST,
payload: {
payload: { data: {
data: newGroupList,
res: true
}
errcode: 0
}}
});
}
}

View File

@ -54,7 +54,7 @@ export default class GroupList extends Component {
<div>{currGroup}</div>
{
groupList.map((group, index) => (
<div key={index}>{group}</div>
<div key={index}>{group.group_name}</div>
))
}
</Card>

View File

@ -11,10 +11,10 @@ const initialState = {
export default (state = initialState, action) => {
switch (action.type) {
case FETCH_GROUP_LIST: {
if (action.payload.res) {
if (!action.payload.data.errcode) {
return {
...state,
groupList: action.payload.data
groupList: action.payload.data.data
};
}
return state;