From: zharkovstas Date: Sun, 19 May 2019 05:16:08 +0000 (+0500) Subject: Allow to close win lightbox X-Git-Url: https://git.xn--bdkaa.com/?a=commitdiff_plain;h=afca4d71aad22b65dbb5f1971d40d938c6a28bf8;p=where-are-you.py.git Allow to close win lightbox --- diff --git a/src/Game.js b/src/Game.js index 6039bdb..ae37a48 100644 --- a/src/Game.js +++ b/src/Game.js @@ -142,7 +142,14 @@ export class Game extends Component { }); }; + startNewGame = () => { + window.location = '/'; + } + onMapClick = (e, map) => { + + if (this.state.isFinished) return; + this.gameController.tryFinish(`${e.latlng.lat}/${e.latlng.lng}`).then(json => { var greenIcon = L.icon({ @@ -162,7 +169,10 @@ export class Game extends Component { 'Игра закончена.', `Неплохая попытка! Вы оказались по адресу: ${json.data.address}, промахнулись на ${Math.round(json.data.distance)} метров и заработали ${Math.round(json.data.score)} очков.`, () => { - window.location = '/'; + + this.setState({ + isFinished: true + }) } ); }).catch(error => { @@ -195,6 +205,19 @@ export class Game extends Component { )} + + {this.state.isFinished && ( +
+
+ +
+
+ )} + + {!this.state.isFinished && ( +
+ + )} +