allianceReducer.js
7.39 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
'use strict';
import InitialState from './allianceInitialState';
import Immutable from 'immutable';
const {
SHOW_HELP_DIALOG,
DISMISS_HELP_DIALOG,
SHOW_WITHDRAW_DIALOG,
DISMISS_WITHDRAW_DIALOG,
SET_ORDER_CODE,
SETTLEMENT_INFO_REQUEST,
SETTLEMENT_INFO_SUCCESS,
SETTLEMENT_INFO_FAILURE,
ADD_SETTLEMENT_REQUEST,
ADD_SETTLEMENT_SUCCESS,
ADD_SETTLEMENT_FAILURE,
RECENTLY_ORDER_REQUEST,
RECENTLY_ORDER_SUCCESS,
RECENTLY_ORDER_FAILURE,
ORDER_DETAIL_REQUEST,
ORDER_DETAIL_SUCCESS,
ORDER_DETAIL_FAILURE,
SETTLEMENT_RECORD_REQUEST,
SETTLEMENT_RECORD_SUCCESS,
SETTLEMENT_RECORD_FAILURE,
ORDER_LIST_REQUEST,
ORDER_LIST_SUCCESS,
ORDER_LIST_FAILURE,
TOP_LIST_REQUEST,
TOP_LIST_SUCCESS,
TOP_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function couponReducer(state = initialState, action) {
if (!(state instanceof InitialState)) {
return initialState.merge(state);
}
switch (action.type) {
case SHOW_HELP_DIALOG: {
return state.set('showHelpDialog', true);
}
case DISMISS_HELP_DIALOG: {
return state.set('showHelpDialog', false);
}
case SHOW_WITHDRAW_DIALOG: {
return state.set('showWithdrawalDialog', true);
}
case DISMISS_WITHDRAW_DIALOG: {
return state.set('showWithdrawalDialog', false);
}
case SET_ORDER_CODE: {
return state.set('orderCode', action.payload);
}
case SETTLEMENT_INFO_REQUEST: {
return state.setIn(['settlementInfo', 'isFetching'], true)
.setIn(['settlementInfo', 'error'], null);
}
case SETTLEMENT_INFO_SUCCESS: {
return state.setIn(['settlementInfo', 'isFetching'], false)
.setIn(['settlementInfo', 'settlementInfoData'], action.payload)
.setIn(['settlementInfo', 'error'], null);
}
case SETTLEMENT_INFO_FAILURE: {
return state.setIn(['settlementInfo', 'isFetching'], false)
.setIn(['settlementInfo', 'error'], action.payload);
}
case ADD_SETTLEMENT_REQUEST: {
return state.setIn(['addSettlement', 'isFetching'], false)
.setIn(['addSettlement', 'error'], action.payload);
}
case ADD_SETTLEMENT_SUCCESS: {
return state.setIn(['addSettlement', 'isFetching'], true)
.setIn(['addSettlement', 'error'], null);
}
case ADD_SETTLEMENT_FAILURE: {
return state.setIn(['addSettlement', 'isFetching'], false)
.set('showWithdrawalDialog', action.payload.isShow)
.setIn(['addSettlement', 'error'], null);
}
case RECENTLY_ORDER_REQUEST: {
return state.setIn(['recentlyOrder', 'isFetching'], true)
.setIn(['recentlyOrder', 'error'], null);
}
case RECENTLY_ORDER_SUCCESS: {
return state.setIn(['recentlyOrder', 'isFetching'], false)
.setIn(['recentlyOrder', 'recentlyOrder_list'], Immutable.fromJS(action.payload))
.setIn(['recentlyOrder', 'error'], null);
}
case RECENTLY_ORDER_FAILURE: {
return state.setIn(['recentlyOrder', 'isFetching'], false)
.setIn(['recentlyOrder', 'error'], action.payload);
}
case ORDER_DETAIL_REQUEST: {
return state.setIn(['orderDetail', 'isFetching'], true)
.setIn(['orderDetail', 'error'], null);
}
case ORDER_DETAIL_SUCCESS: {
let {
amountStr,
orderCode,
orderStatus,
orderTimeStr,
lastOrderAmountStr,
productList,
} = action.payload;
return state.setIn(['orderDetail', 'isFetching'], false)
.setIn(['orderDetail', 'amountStr'], amountStr)
.setIn(['orderDetail', 'orderCode'], orderCode)
.setIn(['orderDetail', 'orderStatus'], orderStatus)
.setIn(['orderDetail', 'orderTimeStr'], orderTimeStr)
.setIn(['orderDetail', 'lastOrderAmountStr'], lastOrderAmountStr)
.setIn(['orderDetail', 'productList'], Immutable.fromJS(productList))
.setIn(['orderDetail', 'error'], null);
}
case ORDER_DETAIL_FAILURE: {
return state.setIn(['orderDetail', 'isFetching'], false)
.setIn(['orderDetail', 'error'], action.payload);
}
case SETTLEMENT_RECORD_REQUEST: {
return state.setIn(['settlementRecordList', 'isFetching'], true)
.setIn(['settlementRecordList', 'error'], null);
}
case SETTLEMENT_RECORD_SUCCESS: {
let {
page,
totalPage,
endReached,
list,
} = action.payload;
return state.setIn(['settlementRecordList', 'isFetching'], false)
.setIn(['settlementRecordList', 'page'], page)
.setIn(['settlementRecordList', 'totalPage'], totalPage)
.setIn(['settlementRecordList', 'endReached'], endReached)
.setIn(['settlementRecordList', 'list'], Immutable.fromJS(list))
.setIn(['settlementRecordList', 'error'], null);
}
case SETTLEMENT_RECORD_FAILURE: {
return state.setIn(['settlementRecordList', 'isFetching'], false)
.setIn(['settlementRecordList', 'error'], action.payload);
}
case ORDER_LIST_REQUEST: {
return state.setIn(['orderList', 'isFetching'], true)
.setIn(['orderList', 'error'], null);
}
case ORDER_LIST_SUCCESS: {
let {
page,
totalPage,
endReached,
list,
} = action.payload;
return state.setIn(['orderList', 'isFetching'], false)
.setIn(['orderList', 'page'], page)
.setIn(['orderList', 'totalPage'], totalPage)
.setIn(['orderList', 'endReached'], endReached)
.setIn(['orderList', 'list'], Immutable.fromJS(list))
.setIn(['orderList', 'error'], null);
}
case ORDER_LIST_FAILURE: {
return state.setIn(['orderList', 'isFetching'], false)
.setIn(['orderList', 'error'], action.payload);
}
case TOP_LIST_REQUEST: {
return state.setIn(['topList', 'isFetching'], true)
.setIn(['topList', 'error'], null);
}
case TOP_LIST_SUCCESS: {
let {
page,
page_total,
endReached,
product_list,
} = action.payload;
return state.setIn(['topList', 'isFetching'], false)
.setIn(['topList', 'page'], page)
.setIn(['topList', 'page_total'], page_total)
.setIn(['topList', 'endReached'], endReached)
.setIn(['topList', 'product_list'], Immutable.fromJS(product_list))
.setIn(['topList', 'error'], null);
}
case TOP_LIST_FAILURE: {
return state.setIn(['topList', 'isFetching'], false)
.setIn(['topList', 'error'], action.payload);
}
}
return state;
}