diff --git a/src/components/EditGameForm.js b/src/components/EditGameForm.js index 5e0f9b2390a3a46de1fbd1c1fb48a36b3bbe9426..5a9d67558944c6227711afcd7b8f4c436b813fa8 100644 --- a/src/components/EditGameForm.js +++ b/src/components/EditGameForm.js @@ -31,19 +31,13 @@ export default class EditGameForm extends React.Component { capture_time: 300, confirmation_time: 60, displayColorPicker: false, - saved: false + saved: true }; - - this.handleMapDrag = this.handleMapDrag.bind(this); } - handleError = error => { - this.setState({ errorMsg: error }); - }; - handleChange = e => { const { name, value } = e.target; - this.setState({ [name]: value }); + this.setState({ [name]: value, saved: false }); }; handleFactionAdd = e => { @@ -201,17 +195,7 @@ export default class EditGameForm extends React.Component { } }; - handleMapDrag = e => { - this.setState({ - mapCenter: e.target.getCenter() - }); - }; - - handleMapScroll = e => { - this.setState({ - zoom: e.target.getZoom() - }); - }; + handleMapScroll = e => {}; handleGameSave = e => { e.preventDefault(); @@ -461,7 +445,7 @@ export default class EditGameForm extends React.Component { onSubmit={this.handleObjectivePointAdd} /> - <h1>Demo Game Editor</h1> + <h1>Game Editor</h1> <br /> <input placeholder="Game name" @@ -635,8 +619,8 @@ export default class EditGameForm extends React.Component { zoom={this.state.zoom} maxZoom="13" style={{ height: "400px", width: "400px" }} - onmoveend={this.handleMapDrag} - onzoomend={this.handleMapScroll} + onmoveend={e => this.setState({ mapCenter: e.target.getCenter() })} + onzoomend={e => this.setState({ zoom: e.target.getZoom() })} > <TileLayer attribution="Maanmittauslaitoksen kartta" diff --git a/src/components/GameView.js b/src/components/GameView.js index 8f1859ef62276669867d227c899f01cb94df50a4..351850e7f7472abc17d8b669ce5790b77cc072c0 100644 --- a/src/components/GameView.js +++ b/src/components/GameView.js @@ -25,8 +25,11 @@ export default class GameView extends React.Component { componentDidMount() { let gameId = new URL(window.location.href).searchParams.get("id"); - let token = sessionStorage.getItem("token"); + this.getGameInfo(gameId); + } + getGameInfo(gameId) { + let token = sessionStorage.getItem("token"); fetch(`${process.env.REACT_APP_API_URL}/game/${gameId}`) .then(res => { if (!res.ok) { @@ -191,16 +194,14 @@ export default class GameView extends React.Component { <EditGameForm gameId={this.state.gameInfo.id} toggleView={() => this.setState({ form: "" })} - onEditSave={() => { - this.getGameInfo(); - }} + onEditSave={() => this.getGameInfo(this.state.gameInfo.id)} /> )} {this.state.form === "join" && ( <JoinGameForm gameId={this.state.gameInfo.id} toggleView={() => this.setState({ form: "" })} - onJoin={() => console.log("joinde")} + onJoin={() => console.log("joined")} /> )} {this.state.form === "players" && (