Initial commit
This commit is contained in:
16
src/reducers/collections.js
Normal file
16
src/reducers/collections.js
Normal 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
15
src/reducers/config.js
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user