35 lines
626 B
JavaScript
Raw Normal View History

/*
*
* List reducer
*
*/
import { fromJS } from 'immutable';
import {
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({
loading: true,
currentModel: null,
models: {}
});
function listReducer(state = initialState, action) {
switch (action.type) {
2017-01-23 20:04:12 +01:00
case LOAD_RECORDS:
return state
.set('loading', true)
.set('currentModel', action.model);
case LOADED_RECORDS:
return state
.set('loading', false)
.setIn(['models', state.get('currentModel')], action.records);
default:
return state;
}
}
export default listReducer;