@shopgate/engage
Version:
Shopgate's ENGAGE library.
6 lines • 1.06 kB
JavaScript
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{REQUEST_CORE_CONFIG,RECEIVE_CORE_CONFIG,ERROR_CORE_CONFIG,CONFIG_LIFETIME}from"./config.constants";/**
* Stores the product locations by the ID of the product.
* @param {Object} [state={}] The current state.
* @param {Object} action The action object.
* @return {Object} The new state.
*/export default function config(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_CORE_CONFIG:return _extends({},state,{isFetching:true,expires:0});case RECEIVE_CORE_CONFIG:return _extends({},state,{},action.config,{isFetching:false,expires:Date.now()+CONFIG_LIFETIME});case ERROR_CORE_CONFIG:return _extends({},state,{isFetching:false,expires:0});default:return state;}}