Last active
December 9, 2016 23:05
-
-
Save lkacenja/515ac8c4025000a6a209e3b33ab6a02d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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