UNPKG

contiago-toolbar

Version:

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

46 lines (41 loc) 1.26 kB
import { fromJS } from 'immutable'; import { LOAD_TOOLBAR_OUTPUT_CONFIG, LOAD_TOOLBAR_OUTPUT_CONFIG_ERROR, LOAD_TOOLBAR_OUTPUT_CONFIG_SUCCESS, SET_TOOLBAR_POSITION, GET_RANDOM_ARTICLES, GET_RANDOM_ARTICLES_ERROR, GET_RANDOM_ARTICLES_SUCCESS, } from './constants'; const initialState = fromJS({ toolbarConfig: {}, outputAccessToken: null, loading: false, error: false, toolbarPosition: {}, randomArticles: [], }); function appReducer(state = initialState, action) { switch (action.type) { case LOAD_TOOLBAR_OUTPUT_CONFIG: case GET_RANDOM_ARTICLES: return state.set('loading', true) .set('error', false); case LOAD_TOOLBAR_OUTPUT_CONFIG_SUCCESS: return state.set('loading', false) .set('toolbarConfig', action.payload); case LOAD_TOOLBAR_OUTPUT_CONFIG_ERROR: case GET_RANDOM_ARTICLES_ERROR: return state.set('loading', false) .set('error', action.payload); case GET_RANDOM_ARTICLES_SUCCESS: return state.set('loading', false) .set('randomArticles', action.payload); case SET_TOOLBAR_POSITION: return state.set('toolbarPosition', action.payload); default: return state; } } export default appReducer;