Created
November 1, 2016 17:47
-
-
Save anonymous/32b4891ec154df47fa1313b5d8dc65d9 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) => { | |
return { | |
...result, | |
[item.highway]: { | |
...result[item.highway], | |
[item.district]: { | |
...(result[item.highway] ? result[item.highway][item.district] : {}), | |
[item.segment]: item, | |
} | |
}, | |
} | |
}, {}), | |
} | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am going to jail for this code