UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

6 lines 1.32 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;}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_MENU,RECEIVE_MENU,ERROR_MENU}from"../../constants/ActionTypes";/** * Stores the entries of the service menu. * @param {Object} [state] The current state. * @param {Object} action The action object. * @return {Object} The new state. */export default function menusByIdReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{isFetching:true})));}case RECEIVE_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{entries:action.entries,isFetching:false})));}case ERROR_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{isFetching:false})));}default:return state;}}