addCouponReducer.js
955 Bytes
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
'use strict';
import InitialState from './addCouponInitialState';
import Immutable, {Map} from 'immutable';
const {
ADD_COUPON_REQUEST,
ADD_COUPON_SUCCESS,
ADD_COUPON_FAILURE,
RESETRECEIVECOUPONRES,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function detailReducer(state=initialState, action) {
switch(action.type) {
case ADD_COUPON_REQUEST: {
return state.set('isFetching', true)
.set('error', null);
}
case ADD_COUPON_SUCCESS: {
return state.set('isFetching', false)
.set('message', '领取成功')
.set('showMessage', true);
}
case ADD_COUPON_FAILURE: {
return state.set('isFetching', false)
.set('error', action.payload)
.set('message', action.payload.message)
.set('showMessage', true);
}
case RESETRECEIVECOUPONRES: {
return state.set('message', '').set('showMessage', false);
}
break;
}
return state;
}