UNPKG

contiago-toolbar

Version:

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

36 lines (32 loc) 812 B
import { fromJS } from 'immutable'; import { GET_ARTICLE, GET_ARTICLE_SUCCESS, GET_ARTICLE_ERROR, SET_PREVIEW_IMAGE, } from './constants'; const initialState = fromJS({ loading: false, error: {}, article: {}, previewImage: {}, }); function articlePageReducer(state = initialState, action) { switch (action.type) { case GET_ARTICLE: return state.set('loading', true) .set('error', {}); case GET_ARTICLE_SUCCESS: return state.set('loading', false) .set('error', {}) .set('article', action.payload); case GET_ARTICLE_ERROR: return state.set('loading', false) .set('error', action.payload); case SET_PREVIEW_IMAGE: return state.set('previewImage', action.payload); default: return state; } } export default articlePageReducer;