@shopgate/engage
Version:
Shopgate's ENGAGE library.
9 lines • 1.02 kB
JavaScript
import{produce}from'immer';import{isDev}from'@shopgate/engage/core/helpers';import{DEVELOPMENT_TOOLS_UPDATE_STATUS_BAR_STYLE_STORAGE}from"../constants";/**
* @typedef {Object} DevToolsStorageState
* @property {Object} statusBarStyle
*/ /** @type DevToolsStorageState */var initialState={statusBarStyle:{styles:{}}};/**
* The reducer for all developer tools storage related states.
* @param {Object} state The application state.
* @param {Object} action The redux action.
* @returns {Object}
*/export default function storageReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(/** @param {DevToolsStorageState} draft The draft */function(draft){if(!isDev){return;}switch(action.type){case DEVELOPMENT_TOOLS_UPDATE_STATUS_BAR_STYLE_STORAGE:{draft.statusBarStyle=action.style;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}