fix: js path

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

View File

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

View File

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

View File

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