]> git.cworth.org Git - lmno.games/blobdiff - tictactoe/tictactoe.jsx
tictactoe: Improve player-info block for the case of no assigned team
[lmno.games] / tictactoe / tictactoe.jsx
index f1426ecff4f443c8837237fffd8caeef3f751153..f5951f1ff26a4bb738dd26a13c74f13feed08ccf 100644 (file)
@@ -72,6 +72,9 @@ events.addEventListener("game-state", event => {
  *********************************************************/
 
 function GameInfo(props) {
+  if (! props.id)
+    return null;
+
   return (
     <div className="game-info">
       <h2>{props.id}</h2>
@@ -81,10 +84,14 @@ function GameInfo(props) {
 }
 
 function PlayerInfo(props) {
+  if (! props.id)
+    return null;
+
   return (
     <div className="player-info">
       <h2>Player</h2>
-      {props.name}, ID: {props.id}, on team: {props.team}
+      {props.name}, ID: {props.id},
+      {props.team ? ` on team ${props.team}` : " not on a team"}
     </div>
   );
 }