orderDetailReducer.js
2.67 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
61
62
63
64
65
66
67
68
69
70
'use strict';
import InitialState from './orderDetailInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_ERROR,
SET_TIP_MESSAGE,
SET_ORDER_CODE,
GET_ORDER_DETAIL_REQUEST,
GET_ORDER_DETAIL_FAILURE,
GET_ORDER_DETAIL_SUCCESS,
SET_BANK_SAFE_PAY_VIEW_STATUS,
SET_CHANGE_BANK_CARD_VIEW_STATUS,
SET_PAY_CARD,
SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
UPDATE_ORDER_INFO_AND_FORMATE_DATA,
SET_BANK_CARDS_LIST_AND_PAY_CARD,
UPDATE_REPAY_TERM_LIST,
UPDATE_PREPAY_SUCCESS_PARAM,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
switch (action.type) {
case SET_ERROR:
return state.set('error',action.payload);
case SET_TIP_MESSAGE:
return state.set('tipMessage', action.payload);
case SET_ORDER_CODE:
return state.set('orderCode', action.payload);
case GET_ORDER_DETAIL_REQUEST:
return state.set('isFetching', true)
.set('error', null);
case GET_ORDER_DETAIL_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
case GET_ORDER_DETAIL_SUCCESS:
return state.set('isFetching', false)
.set('error', null)
.set('orderInfo', Immutable.fromJS(action.payload));
case SET_BANK_SAFE_PAY_VIEW_STATUS:
return state.set('showBankSafePayView',action.payload);
case SET_CHANGE_BANK_CARD_VIEW_STATUS:
return state.set('showChangeBankView',action.payload);
case SET_SHOW_CONFIRM_PAY_VIEW_STATUS:
return state.set('showConfirmPayView', action.payload);
case UPDATE_ORDER_INFO_AND_FORMATE_DATA:
return state.setIn(['orderInfo', 'package_list'], Immutable.fromJS(action.payload.package_list))
.set('formateData', Immutable.fromJS(action.payload.formateData));
case SET_BANK_CARDS_LIST_AND_PAY_CARD:
return state.set('bankCardsList', Immutable.fromJS(action.payload))
.set('payCard', Immutable.fromJS(action.payload[0]));
case SET_PAY_CARD:
return state.set('payCard', Immutable.fromJS(action.payload));
case UPDATE_REPAY_TERM_LIST:
return state.set('repayTermList', Immutable.fromJS(action.payload));
case UPDATE_PREPAY_SUCCESS_PARAM:
return state.set('prePaySuccessParam',Immutable.fromJS(action.payload))
.set('showConfirmPayView', true);
}
return state;
}