repayListReducer.js
2.42 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
'use strict';
import InitialState from './repayListInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_QUERY_DAYS,
SET_ERROR,
QUERY_REPAYMENT_LIST_REQUEST,
QUERY_REPAYMENT_LIST_FAILURE,
QUERY_REPAYMENT_LIST_SUCCESS,
SET_FORMATE_DATA,
SET_TIP_MESSAGE,
UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA,
SET_BANK_CARDS_LIST_AND_PAY_CARD,
SET_BANK_SAFE_PAY_VIEW_STATUS,
UPDATE_REPAY_TERM_LIST,
UPDATE_PREPAY_SUCCESS_PARAM,
SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case SET_QUERY_DAYS:
return state.set('queryDays', action.payload);
case QUERY_REPAYMENT_LIST_REQUEST:
return state.set('isFetching', true)
.set('error', null);
case SET_ERROR:
case QUERY_REPAYMENT_LIST_FAILURE:
return state.set('isFetching', false)
.set('error',action.payload);
case UPDATE_REPAYMENT_LIST_AND_FORMATE_DATA:
return state.set('repaymentList', Immutable.fromJS(action.payload.repaymentList))
.set('formateData', Immutable.fromJS(action.payload.formateData));
case QUERY_REPAYMENT_LIST_SUCCESS:
return state.set('repaymentList', Immutable.fromJS(action.payload))
.set('isFetching', false);
case SET_FORMATE_DATA:
return state.set('formateData', Immutable.fromJS(action.payload));
case SET_TIP_MESSAGE:
return state.set('tipMessage', action.payload);
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_BANK_SAFE_PAY_VIEW_STATUS:
return state.set('showBankSafePayView',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);
case SET_SHOW_CONFIRM_PAY_VIEW_STATUS:
return state.set('showConfirmPayView', action.payload);
}
return state;
}