diff --git a/src/components/EditGameForm.js b/src/components/EditGameForm.js index 55247e638269ca8cb9d888d972cc9ec75aa08857..a72a05aa8b55a810c89209bb7700bd631fc3e394 100644 --- a/src/components/EditGameForm.js +++ b/src/components/EditGameForm.js @@ -177,6 +177,7 @@ export class EditGameForm extends React.Component { .then(result => { console.log(result); this.handleView(); + this.props.onEditSave(); }) .catch(error => console.log(error)); } @@ -267,6 +268,7 @@ export class EditGameForm extends React.Component { }) .then(result => { alert(result.message); + this.props.onEditSave(); this.handleView(); }) .catch(error => console.log("Error: ", error)); @@ -305,6 +307,7 @@ export class EditGameForm extends React.Component { .then(result => { let factions = result.map(faction => { return { + factionId: faction.factionId, factionName: faction.factionName, factionPassword: faction.factionPassword, multiplier: 1, @@ -315,6 +318,7 @@ export class EditGameForm extends React.Component { // Remove objective point's id from the object let objectivePoints = json.objective_points.map(point => { return { + objectivePointId: point.objectivePointId, objectivePointDescription: point.objectivePointDescription, objectivePointMultiplier: point.objectivePointMultiplier }; diff --git a/src/components/GameCard.js b/src/components/GameCard.js index 6cb651662501e66f3c0e609498de701b09904a02..bb54f1a2093baa9a91fe4adf0aaaa821e84c29fb 100644 --- a/src/components/GameCard.js +++ b/src/components/GameCard.js @@ -10,6 +10,10 @@ export default class GameCard extends React.Component { // Get game info componentDidMount() { + this.getGameInfo(); + } + + getGameInfo() { fetch(`${process.env.REACT_APP_API_URL}/game/${this.props.gameId}`) .then(res => { if (res.ok) { @@ -63,6 +67,10 @@ export default class GameCard extends React.Component { <EditGameForm gameId={this.state.gameInfo.id} toggleView={() => this.setState({ editForm: false })} + onEditSave={() => { + this.props.onEditSave(); + this.getGameInfo(); + }} /> )} </div> diff --git a/src/components/GameList.js b/src/components/GameList.js index f756ade27443c6c050700c57beb96ef7461d9c55..7427988696e515c52def6e7a3ac5074572334863 100644 --- a/src/components/GameList.js +++ b/src/components/GameList.js @@ -8,7 +8,7 @@ class GameList extends React.Component { <GameCard key={game.id} gameId={game.id} - onEditSave={() => this.getGames()} + onEditSave={this.props.onEditSave} /> ); }); diff --git a/src/components/GameSelection.js b/src/components/GameSelection.js index db948cde0de61927ebe8fdbd463797c6cd9c1b1c..9759aec330ff953a7c6d13c50ecc89860ccade69 100644 --- a/src/components/GameSelection.js +++ b/src/components/GameSelection.js @@ -49,7 +49,12 @@ export default class GameSelection extends React.Component { } /> )} - <GameList games={this.state.games} /> + <GameList + games={this.state.games} + onEditSave={() => { + this.getGames(); + }} + /> </div> ); }