UNPKG

@shopgate/engage

Version:
6 lines 1.78 kB
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{produce}from'immer';import appConfig from'@shopgate/pwa-common/helpers/config';import{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING}from"../constants";var _appConfig$locales=appConfig.locales,_appConfig$locales2=_appConfig$locales===void 0?{}:_appConfig$locales,_appConfig$locales2$c=_appConfig$locales2.currency,currency=_appConfig$locales2$c===void 0?null:_appConfig$locales2$c;var defaultState=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,false),MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,false),MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,false),MERCHANT_SETTINGS_DEFAULT_CURRENCY,currency),MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,false);/** * Stores the merchant settings. * @param {Object} [state={}] The current state. * @param {Object} action The action object. * @returns {Object} The new state. */export default function merchantSettings(){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 RECEIVE_MERCHANT_SETTINGS:{Object.keys(action.settings).forEach(function(key){draft[key]=action.settings[key];});break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}