cardAddReducer.js
2.02 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 './cardAddInitialState';
import Immutable, {Map} from 'immutable';
const {
SHOW_BANK_INFO,
SHOW_RESULT_INFO,
RESET_CARD_ADD_INFO,
SET_USER_NAME,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function cardAddReducer(state = initialState, action) {
//if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case SET_USER_NAME:
return state.set('userName', action.payload)
case SHOW_BANK_INFO:
return state.set('bankCode', action.payload.bankCode)
.set('bankName', action.payload.bankName)
.set('cardNO', action.payload.cardNO)
.set('bankSupport', action.payload.bankSupport)
.set('showBankInfo', action.payload.showBankInfo);
case SHOW_RESULT_INFO:
return state.set('showResult', action.payload.showResult)
.set('result', action.payload.result)
.set('message', action.payload.message)
.set('description', action.payload.description)
.set('buttonText', action.payload.buttonText);
case RESET_CARD_ADD_INFO:
return state.set('bankCode', action.payload.bankCode)
.set('bankName', action.payload.bankName)
.set('cardNO', action.payload.cardNO)
.set('bankSupport', action.payload.bankSupport)
.set('showBankInfo', action.payload.showBankInfo)
.set('showResult', action.payload.showResult)
.set('result', action.payload.result)
.set('message', action.payload.message)
.set('description', action.payload.description)
.set('buttonText', action.payload.buttonText);
}
return state;
}