Test repo can now be used to list entries
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
import Immutable from 'immutable';
|
||||
import { OrderedMap, fromJS } from 'immutable';
|
||||
import { CONFIG_SUCCESS } from '../actions/config';
|
||||
import { ENTRIES_REQUEST, ENTRIES_SUCCESS } from '../actions/entries';
|
||||
|
||||
export function collections(state = null, action) {
|
||||
switch (action.type) {
|
||||
case CONFIG_SUCCESS:
|
||||
const collections = action.payload && action.payload.collections;
|
||||
return Immutable.OrderedMap().withMutations((map) => {
|
||||
return OrderedMap().withMutations((map) => {
|
||||
(collections || []).forEach(function(collection) {
|
||||
map.set(collection.name, Immutable.fromJS(collection));
|
||||
map.set(collection.name, fromJS(collection));
|
||||
});
|
||||
});
|
||||
case ENTRIES_REQUEST:
|
||||
return state && state.setIn([action.payload.collection, 'isFetching'], true);
|
||||
case ENTRIES_SUCCESS:
|
||||
return state && state.setIn([action.payload.collection, 'entries'], fromJS(action.payload.entries));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Reference in New Issue
Block a user