Filter out already used popular suggestions

This commit is contained in:
Aaron Lindsay 2016-12-29 21:22:00 -05:00
parent 49409f84d2
commit 298b3b7cea

View File

@ -82,6 +82,21 @@ module.exports = React.createClass({
suggestion.RestaurantName = this.state.suggestion;
suggestion.VetoingId = this.getLastSuggestion();
this.props.createSuggestion(suggestion);
this.setState({
attendee: null,
suggestion: null
});
},
unusedPopularSuggestions: function() {
var props = this.props;
return props.popularSuggestions.filter(
function(suggestion){
for (var suggestionId in props.suggestions) {
if (props.suggestions[suggestionId].RestaurantName == suggestion.RestaurantName)
return false;
}
return true;
});
},
render: function() {
var attendeeList = this.getAttendeeList();
@ -101,7 +116,7 @@ module.exports = React.createClass({
<Col xs={4}>
<Combobox
value={this.state.suggestion}
data={this.props.popularSuggestions}
data={this.unusedPopularSuggestions()}
valueField='RestaurantName'
textField='RestaurantName'
onChange={this.onChangeSuggestion} />