purchaseCodeReducer.js
1.49 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
'use strict';
import InitialState from './purchaseCodeInitialState';
import Immutable, {Map} from 'immutable';
const {
GET_MINE_LIMIT_PURCHASE_LIST_REQUEST,
GET_MINE_LIMIT_PURCHASE_LIST_SUCCESS,
GET_MINE_LIMIT_PURCHASE_LIST_FAILURE,
DELETE_MINE_LIMIT_PURCHASE_REQUEST,
DELETE_MINE_LIMIT_PURCHASE_SUCCESS,
DELETE_MINE_LIMIT_PURCHASE_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function detailReducer(state=initialState, action) {
switch(action.type) {
case GET_MINE_LIMIT_PURCHASE_LIST_REQUEST: {
return state.set('isFetching', true)
.set('error', null);
}
case GET_MINE_LIMIT_PURCHASE_LIST_SUCCESS: {
return state.set('isFetching', false)
.set('error', null)
.set('invalidLimitCodeProducts', Immutable.fromJS(action.payload.invalidLimitCodeProducts))
.set('limitCodeProducts', Immutable.fromJS(action.payload.limitCodeProducts));
}
case GET_MINE_LIMIT_PURCHASE_LIST_FAILURE: {
return state.set('isFetching', false)
.set('error', action.payload);
}
case DELETE_MINE_LIMIT_PURCHASE_REQUEST: {
return state.set('isFetching', true)
.set('error', null);
}
case DELETE_MINE_LIMIT_PURCHASE_SUCCESS: {
return state.set('isFetching', false)
.set('error', null)
.set('invalidLimitCodeProducts', Immutable.fromJS(action.payload))
}
case DELETE_MINE_LIMIT_PURCHASE_FAILURE: {
return state.set('isFetching', false)
.set('error', action.payload);
}
}
return state;
}