yearActivityReducer.js
1.21 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
'use strict';
import InitialState from './yearActivityInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_TYPE,
SET_SIMILAR_PRODUCT_INDEX,
GET_YEARACTIVITY_PRODUCT_REQUEST,
GET_YEARACTIVITY_PRODUCT_SUCCESS,
GET_YEARACTIVITY_PRODUCT_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function yearActivityReducer(state=initialState, action) {
switch(action.type) {
case SET_TYPE: {
return state.set('type', action.payload);
}
case SET_SIMILAR_PRODUCT_INDEX: {
return state.set('similarIndex', action.payload.rowID);
}
case GET_YEARACTIVITY_PRODUCT_REQUEST: {
return state.set('isFetching', true);
}
case GET_YEARACTIVITY_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_YEARACTIVITY_PRODUCT_FAILURE: {
return state.set('isFetching', false);
}
}
return state;
}