static-cms/src/reducers/collections.js

17 lines
509 B
JavaScript
Raw Normal View History

2016-02-25 00:45:56 -08:00
import Immutable from 'immutable';
import { CONFIG_SUCCESS } from '../actions/config';
2016-02-25 00:45:56 -08:00
export function collections(state = null, action) {
switch (action.type) {
case CONFIG_SUCCESS:
2016-02-25 00:45:56 -08:00
const collections = action.payload && action.payload.collections;
return Immutable.OrderedMap().withMutations((map) => {
(collections || []).forEach(function(collection) {
map.set(collection.name, Immutable.fromJS(collection));
});
});
default:
return state;
}
}