Skip to content
Snippets Groups Projects
Commit 7895ffd8 authored by Joni Laukka's avatar Joni Laukka
Browse files

Gamelist updates if the list changes (add, edit, delete)

parent a2db82d7
No related branches found
No related tags found
2 merge requests!31Development,!28Routing
......@@ -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
};
......
......@@ -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>
......
......@@ -8,7 +8,7 @@ class GameList extends React.Component {
<GameCard
key={game.id}
gameId={game.id}
onEditSave={() => this.getGames()}
onEditSave={this.props.onEditSave}
/>
);
});
......
......@@ -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>
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment