@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 893 B
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{SET_USER_GEOLOCATION,USER_SEARCH_GEOLOCATION_LIFETIME}from"../constants";export var defaultState={geolocation:null};/**
* @param {Object} state The current state.
* @param {Object} action The action Object
* @returns {Object} The new state.
*/export default function user(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case SET_USER_GEOLOCATION:return _extends({},state,{geolocation:_extends({},action.geolocation,{expires:Date.now()+USER_SEARCH_GEOLOCATION_LIFETIME})});default:return state;}}