@shopgate/pwa-common-commerce
Version:
Commerce library for the Shopgate Connect PWA.
6 lines • 763 B
JavaScript
import{produce}from'immer';import{SET_COUPON_FIELD_VALUE,SET_COUPON_FIELD_ERROR}from"../constants";var defaultState={error:'',value:''};/**
* The reducer for all checkout related state.
* @param {Object} state The application state.
* @param {Object} action The redux action.
* @returns {Object}
*/export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case SET_COUPON_FIELD_VALUE:{draft.value=action.value;break;}case SET_COUPON_FIELD_ERROR:{draft.error=action.message;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);});