Skip to content

Instantly share code, notes, and snippets.

@JDeuce
Forked from anonymous/index.js
Last active November 1, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JDeuce/5b679d3850f8b0d7fbca7b8c9a1c669b to your computer and use it in GitHub Desktop.
Save JDeuce/5b679d3850f8b0d7fbca7b8c9a1c669b to your computer and use it in GitHub Desktop.
const segments = (state = {}, action) => {
switch (action.type) {
case actions.LOAD_SEGMENTS:
return {
...state,
segments: action.segments
.map(segments => segments.values_)
.reduce((result, item) => {
result[item.highway] = result[item.highway] || {};
result[item.highway][item.district] = result[item.highway][item.district] || {};
result[item.highway][item.district][item.segment] = item;
return result;
}, {}),
}
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment