Initial commit

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 00:45:56 -08:00
commit c60d8ba706
19 changed files with 590 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import Immutable from 'immutable';
import { CONFIG } from '../actions/config';
export function collections(state = null, action) {
switch (action.type) {
case CONFIG.SUCCESS:
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;
}
}

15
src/reducers/config.js Normal file
View File

@ -0,0 +1,15 @@
import Immutable from 'immutable';
import { CONFIG } from '../actions/config';
export function config(state = null, action) {
switch (action.type) {
case CONFIG.REQUEST:
return Immutable.Map({isFetching: true});
case CONFIG.SUCCESS:
return Immutable.fromJS(action.payload);
case CONFIG.FAILURE:
return Immutable.Map({error: action.payload.toString()});
default:
return state;
}
}