contiago-toolbar
Version:
One of the options for outputting content from contiago xml-server
44 lines (40 loc) • 1.11 kB
JavaScript
import { fromJS } from 'immutable';
import {
GET_RUBRIC_CONTENT,
GET_RUBRIC_CONTENT_SUCCESS,
GET_RUBRIC_CONTENT_ERROR,
SET_CURRENT_PAGE,
SET_TOTAL_PAGES_AMOUNT,
SET_PAGE_SIZE,
} from './constants';
const initialState = fromJS({
rubricContent: {},
loading: false,
error: {},
pageNumber: 0,
pageSize: 6,
pagesAmount: 0,
});
function rubricContentReducer(state = initialState, action) {
switch (action.type) {
case GET_RUBRIC_CONTENT:
return state.set('loading', true)
.set('error', {});
case GET_RUBRIC_CONTENT_SUCCESS:
return state.set('rubricContent', action.payload)
.set('loading', false)
.set('error', {});
case GET_RUBRIC_CONTENT_ERROR:
return state.set('loading', false)
.set('error', action.payload);
case SET_CURRENT_PAGE:
return state.set('pageNumber', action.payload);
case SET_TOTAL_PAGES_AMOUNT:
return state.set('pagesAmount', action.payload);
case SET_PAGE_SIZE:
return state.set('pageSize', action.payload);
default:
return state;
}
}
export default rubricContentReducer;