Last active
August 29, 2015 14:14
-
-
Save kossnocorp/14d7dd37202dae944d0c 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
var noLocationStr = function(origin) { | |
return !!origin.get('location_str'); | |
}; | |
var withStatus = function(foreignKey, statuses, origin) { | |
return origin | |
.set('status', statuses.find(s => s.get(foreignKey) == origin.get('id'))); | |
}; | |
var withLocation = function(locations, locationStr, origin) { | |
return origin | |
.set( | |
'location', | |
locations.find(l => l.get('location_strs').contains(locationStr)) | |
); | |
}; | |
var hasExtremeLocation = function(origin) { | |
return origin.getIn(['location', 'extreme?']); | |
} | |
var collectEngineers = function(data) { | |
return t.sequence( | |
t.combine( | |
t.filter(noLocationStr), | |
t.map(withStatus.bind('engineer_id', data.get('statuses'))) | |
t.map(withLocation.bind(data.get('locations'))) | |
t.filter(hasExtremeLocation) | |
), | |
data.get('engineers') | |
); | |
}; | |
var uiState = I.Map({ | |
engineers: collectEngineers(data) | |
}); | |
React.render(<Engineers engineers={uiState.get('engineers')} />, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment