Skip to content

Instantly share code, notes, and snippets.

@lkacenja
Last active December 9, 2016 23:05
Show Gist options
  • Save lkacenja/515ac8c4025000a6a209e3b33ab6a02d to your computer and use it in GitHub Desktop.
Save lkacenja/515ac8c4025000a6a209e3b33ab6a02d to your computer and use it in GitHub Desktop.
import assign from 'object-assign';
import actionTypes from '../utility/action-types';
export default function = function(settings) {
const defaultState = {
config: settings.filters,
values: {}
};
for (var x in filters) {
if (filters[x].default_value) {
defaultState.values[x] = filters[x].default_value;
}
}
return function(state, action) {
switch (action.type) {
case actionTypes.UPDATE_FILTERS:
var newValues = assign({}, defaultState.values, JSON.parse(action.values));
return assign({}, state, {values: newValues});
default:
return assign({}, defaultState, state);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment