From 298b3b7ceaca4378de50c2a53864c7c5b21fc5ed Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Thu, 29 Dec 2016 21:22:00 -0500 Subject: [PATCH] Filter out already used popular suggestions --- js/components/NewSuggestion.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js/components/NewSuggestion.js b/js/components/NewSuggestion.js index 918a251..c9b8ddf 100644 --- a/js/components/NewSuggestion.js +++ b/js/components/NewSuggestion.js @@ -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({