From 6548dce699432ed9f43222793785ce51dc28f3ab Mon Sep 17 00:00:00 2001
From: Joni Laukka <jonilaukka@hotmail.com>
Date: Wed, 10 Jul 2019 21:52:06 +0300
Subject: [PATCH] send and receive faction colour

---
 src/components/EditGameForm.js | 19 ++++++++++++-------
 src/components/GameList.js     |  2 +-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/components/EditGameForm.js b/src/components/EditGameForm.js
index 0987f0d..378142c 100644
--- a/src/components/EditGameForm.js
+++ b/src/components/EditGameForm.js
@@ -23,14 +23,14 @@ export class EditGameForm extends React.Component {
       },
       factionNameInput: "", // >= 2 chars
       factionPasswordInput: "", // >= 3 chars
+      factionColorInput: "#852222",
       factions: [],
       objectivePointDescriptionInput: "", // >= 7
       objectivePointMultiplierInput: "", // number
       objectivePoints: [],
       capture_time: 300,
       confirmation_time: 60,
-      displayColorPicker: false,
-      color: "#852222"
+      displayColorPicker: false
     };
 
     this.handleMapDrag = this.handleMapDrag.bind(this);
@@ -67,9 +67,11 @@ export class EditGameForm extends React.Component {
 
     this.setState(state => {
       let factions = state.factions;
+      console.log(this.state.factionColorInput);
       factions.push({
         factionName: this.state.factionNameInput,
         factionPassword: this.state.factionPasswordInput,
+        colour: this.state.factionColorInput,
         multiplier: 1
       });
       return {
@@ -302,7 +304,8 @@ export class EditGameForm extends React.Component {
           return {
             factionName: faction.factionName,
             factionPassword: faction.factionPassword,
-            multiplier: 1
+            multiplier: 1,
+            colour: faction.colour
           };
         });
 
@@ -353,7 +356,7 @@ export class EditGameForm extends React.Component {
       const faction = this.state.factions[i];
       factions.push(
         <li key={faction.factionName}>
-          <div>
+          <div style={{ color: faction.colour }}>
             {faction.factionName} : {faction.factionPassword}
           </div>
           <button
@@ -392,7 +395,7 @@ export class EditGameForm extends React.Component {
           width: "36px",
           height: "14px",
           borderRadius: "2px",
-          background: `${this.state.color}`
+          background: `${this.state.factionColorInput}`
         },
         swatch: {
           padding: "5px",
@@ -540,8 +543,10 @@ export class EditGameForm extends React.Component {
               onClick={() => this.setState({ displayColorPicker: false })}
             >
               <SketchPicker
-                color={this.state.color}
-                onChangeComplete={color => this.setState({ color: color.hex })}
+                color={this.state.factionColorInput}
+                onChangeComplete={color =>
+                  this.setState({ factionColorInput: color.hex })
+                }
               />
             </div>
           )}
diff --git a/src/components/GameList.js b/src/components/GameList.js
index 3a3724d..aa8d330 100644
--- a/src/components/GameList.js
+++ b/src/components/GameList.js
@@ -51,7 +51,7 @@ class GameList extends React.Component {
       },
       () => {
         // taking the changed gameID to UserMap.js (GameList.js -> Header.js -> App.js -> UserMap.js)
-        this.props.handleGameChange(this.state.selectedGame);
+        //this.props.handleGameChange(this.state.selectedGame);
       }
     );
   };
-- 
GitLab