...
|
...
|
@@ -4,37 +4,112 @@ import InitialState from './associatorGiftInitialState'; |
|
|
import Immutable, {Map} from 'immutable';
|
|
|
|
|
|
const {
|
|
|
SHOWGIFTALERT,
|
|
|
DISMISSGIFTALERT,
|
|
|
SHOWGIFTALERT,
|
|
|
DISMISSGIFTALERT,
|
|
|
|
|
|
COUPONS_BAG_REQUEST,
|
|
|
COUPONS_BAG_SUCCESS,
|
|
|
COUPONS_BAG_FAILURE,
|
|
|
|
|
|
ASSOCIATORGIFT_PRODUCT_REQUEST,
|
|
|
ASSOCIATORGIFT_PRODUCT_SUCCESS,
|
|
|
ASSOCIATORGIFT_PRODUCT_FAILURE,
|
|
|
|
|
|
DRAW_COUPONS_BAG_REQUEST,
|
|
|
DRAW_COUPONS_BAG_SUCCESS,
|
|
|
DRAW_COUPONS_BAG_FAILURE,
|
|
|
|
|
|
COUPONS_BAG_CNT_REQUEST,
|
|
|
COUPONS_BAG_CNT_SUCCESS,
|
|
|
COUPONS_BAG_CNT_FAILURE,
|
|
|
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
const initialState = new InitialState;
|
|
|
|
|
|
export default function couponReducer(state=initialState, action) {
|
|
|
if (!(state instanceof InitialState)) {
|
|
|
export default function couponReducer(state = initialState, action) {
|
|
|
if (!(state instanceof InitialState)) {
|
|
|
return initialState.merge(state);
|
|
|
}
|
|
|
|
|
|
switch(action.type) {
|
|
|
case SHOWGIFTALERT: {
|
|
|
return state.set('showGiftAlert', true);
|
|
|
}
|
|
|
case DISMISSGIFTALERT: {
|
|
|
return state.set('showGiftAlert', false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
switch (action.type) {
|
|
|
case SHOWGIFTALERT: {
|
|
|
return state.set('showGiftAlert', true);
|
|
|
}
|
|
|
case DISMISSGIFTALERT: {
|
|
|
return state.set('showGiftAlert', false);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_REQUEST: {
|
|
|
return state.setIn(['couponsBag', 'isFetching'], true)
|
|
|
.setIn(['couponsBag', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_SUCCESS: {
|
|
|
return state.setIn(['couponsBag', 'isFetching'], false)
|
|
|
.setIn(['couponsBag', 'couponsBag_list'], Immutable.fromJS(action.payload))
|
|
|
.setIn(['couponsBag', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_FAILURE: {
|
|
|
return state.setIn(['couponsBag', 'isFetching'], false)
|
|
|
.setIn(['couponsBag', 'error'], action.payload);
|
|
|
}
|
|
|
|
|
|
case ASSOCIATORGIFT_PRODUCT_REQUEST: {
|
|
|
return state.setIn(['productList', 'isFetching'], true)
|
|
|
.setIn(['productList', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case ASSOCIATORGIFT_PRODUCT_SUCCESS: {
|
|
|
let {
|
|
|
product_list,
|
|
|
rec_id,
|
|
|
} = action.payload;
|
|
|
|
|
|
return state.setIn(['productList', 'product_list'], Immutable.fromJS(product_list))
|
|
|
.setIn(['productList', 'rec_id'], rec_id);
|
|
|
return state.setIn(['productList', 'isFetching'], false)
|
|
|
.setIn(['productList', 'product_list'], Immutable.fromJS(product_list))
|
|
|
.setIn(['productList', 'rec_id'], rec_id)
|
|
|
.setIn(['productList', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case ASSOCIATORGIFT_PRODUCT_FAILURE: {
|
|
|
return state.setIn(['productList', 'error'], Immutable.fromJS(action.payload));
|
|
|
return state.setIn(['productList', 'isFetching'], false)
|
|
|
.setIn(['productList', 'error'], action.payload);
|
|
|
}
|
|
|
|
|
|
case DRAW_COUPONS_BAG_REQUEST: {
|
|
|
return state.setIn(['drawCouponsBag', 'isFetching'], true)
|
|
|
.setIn(['drawCouponsBag', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case DRAW_COUPONS_BAG_SUCCESS: {
|
|
|
return state.setIn(['drawCouponsBag', 'isFetching'], false)
|
|
|
.set('showGiftAlert', action.payload.isShow)
|
|
|
.setIn(['couponsBag', 'couponsBag_list'], Immutable.fromJS(action.payload.couponsBagList))
|
|
|
.setIn(['drawCouponsBag', 'drawCouponsBag_list'], Immutable.fromJS(action.payload.drawCouponsBagList))
|
|
|
.setIn(['drawCouponsBag', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case DRAW_COUPONS_BAG_FAILURE: {
|
|
|
return state.setIn(['drawCouponsBag', 'isFetching'], false)
|
|
|
.setIn(['drawCouponsBag', 'error'], action.payload);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_CNT_REQUEST: {
|
|
|
return state.setIn(['couponsBagCnt', 'isFetching'], true)
|
|
|
.setIn(['couponsBagCnt', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_CNT_SUCCESS: {
|
|
|
return state.setIn(['couponsBagCnt', 'isFetching'], false)
|
|
|
.setIn(['couponsBagCnt', 'total'], action.payload.total)
|
|
|
.setIn(['couponsBagCnt', 'error'], null);
|
|
|
}
|
|
|
|
|
|
case COUPONS_BAG_CNT_FAILURE: {
|
|
|
return state.setIn(['couponsBagCnt', 'isFetching'], false)
|
|
|
.setIn(['couponsBagCnt', 'error'], action.payload);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|