UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

6 lines 583 B
import{CREATE_MODAL,REMOVE_MODAL}from"../../constants/ActionTypes";/** * Stores all the view information. * @param {Object} state The current state. * @param {Object} action The action object. * @return {Object} The new state. */export default function modalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case CREATE_MODAL:return[].concat(state,[action.options]);case REMOVE_MODAL:return state.filter(function(modal){return modal.id!==action.id;});default:return state;}}