fastExpressReducer.js
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
import InitialState from './fastExpressInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_TYPE,
SET_SIMILAR_PRODUCT_INDEX,
GET_FASTEXPRESS_INFO_REQUEST,
GET_FASTEXPRESS_INFO_SUCCESS,
GET_FASTEXPRESS_INFO_FAILURE,
GET_FASTEXPRESS_PRODUCT_REQUEST,
GET_FASTEXPRESS_PRODUCT_SUCCESS,
GET_FASTEXPRESS_PRODUCT_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function fastExpressReducer(state=initialState, action) {
switch(action.type) {
case SET_SIMILAR_PRODUCT_INDEX: {
return state.set('similarIndex', action.payload.rowID);
}
case GET_FASTEXPRESS_INFO_REQUEST: {
return state.set('isFetching', true);
}
case GET_FASTEXPRESS_INFO_SUCCESS:{
return state.set('isFetching', false)
.set('fastExpressList', Immutable.fromJS(action.payload));
}
case GET_FASTEXPRESS_INFO_FAILURE: {
return state.set('isFetching', true);
}
case GET_FASTEXPRESS_PRODUCT_REQUEST: {
return state.set('isFetching', true);
}
case GET_FASTEXPRESS_PRODUCT_SUCCESS:{
let json = action.payload;
return state.set('isFetching', false)
.set('list', Immutable.fromJS(json.list))
.set('currentPage', json.currentPage)
.set('pageCount', json.pageCount)
.set('total', json.total)
.set('endReached', json.endReached);
}
case GET_FASTEXPRESS_PRODUCT_FAILURE: {
return state.set('isFetching', false);
}
}
return state;
}