-
-
Save JDeuce/5b679d3850f8b0d7fbca7b8c9a1c669b to your computer and use it in GitHub Desktop.
This file contains 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
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