UNPKG

contiago-toolbar

Version:

One of the options for outputting content from contiago xml-server

41 lines (35 loc) 1.17 kB
import { fromJS } from 'immutable'; import { combineReducers } from 'redux-immutable'; import { LOCATION_CHANGE, PREVIOUS_LOCATION } from 'utils/router/constants'; import globalReducer from 'containers/App/reducer'; import languageProviderReducer from 'containers/LanguageProvider/reducer'; const routeInitialState = fromJS({ location: 'Home', history: [], }); function routeReducer(state = routeInitialState, action) { switch (action.type) { case LOCATION_CHANGE: return state .set('location', action.newRoute) .set('history', [...state.toJS().history, action.newRoute]); case PREVIOUS_LOCATION: { const history = state.toJS().history; const previousLocation = history[history.length - 2]; const newHistory = [...history.slice(0, history.length - 1)]; return state .set('location', previousLocation) .set('history', newHistory); } default: return state; } } export default function createReducer(injectedReducers) { return combineReducers({ route: routeReducer, global: globalReducer, language: languageProviderReducer, ...injectedReducers, }); }