38 lines
688 B
JavaScript
Raw Normal View History

/*
*
* List reducer
*
*/
import { fromJS } from 'immutable';
import {
SET_CURRENT_MODEL_NAME,
2017-01-23 20:04:12 +01:00
LOAD_RECORDS,
LOADED_RECORDS
} from './constants';
2017-01-23 20:04:12 +01:00
const initialState = fromJS({
currentModel: null,
loading: true,
records: false,
2017-01-23 20:04:12 +01:00
});
function listReducer(state = initialState, action) {
switch (action.type) {
case SET_CURRENT_MODEL_NAME:
2017-01-23 20:04:12 +01:00
return state
.set('currentModelName', action.modelName);
case LOAD_RECORDS:
return state
.set('loading', true);
2017-01-23 20:04:12 +01:00
case LOADED_RECORDS:
return state
.set('loading', false)
.set('records', action.records);
default:
return state;
}
}
export default listReducer;