static-cms/src/reducers/collections.js

19 lines
528 B
JavaScript
Raw Normal View History

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