]> git.cworth.org Git - lmno.games/blobdiff - empathy/empathy.jsx
Add key to list of PromptOption components
[lmno.games] / empathy / empathy.jsx
index 0789b463fe5813cb3fc23b8cb4a84610dd32b2a5..feff7775a99f782188474bab923da9e1580b8327 100644 (file)
@@ -414,7 +414,13 @@ const PromptOptions = React.memo(props => {
         Select any categories below that you'd like to play.
         You can choose as many as you'd like.
       </p>
-    {props.prompts.map(p => <PromptOption prompt={p} player={props.player} />)}
+      {props.prompts.map(
+        prompt => <PromptOption
+                    key={prompt.id}
+                    prompt={prompt}
+                    player={props.player}
+                  />
+      )}
     </div>
   );
 });
@@ -482,7 +488,8 @@ class Ambiguities extends React.PureComponent {
 
     this.state = {
       word_sets: word_sets,
-      selected: null
+      selected: null,
+      starred: null
     };
 
     this.submitted = false;
@@ -497,7 +504,8 @@ class Ambiguities extends React.PureComponent {
 
     const response = await fetch_post_json(
       `judged/${this.props.prompt.id}`,{
-        word_groups: this.state.word_sets.map(set => Array.from(set))
+        word_groups: this.state.word_sets.map(set => Array.from(set)),
+        kudos: Array.from(this.state.starred)
       }
     );
 
@@ -684,6 +692,21 @@ class Ambiguities extends React.PureComponent {
                   </button>
                 );
               })}
+              <span
+                className={this.state.starred === set ?
+                           "star-button selected" : "star-button"
+                          }
+                onClick={(event) => {
+                  event.stopPropagation();
+                  this.setState({
+                    starred: set
+                  });
+                }}
+              >
+              {this.state.starred === set ?
+               '★' : '☆'
+              }
+              </span>
             </div>
           );
         })}