});
};
+ 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({
'Игра закончена.',
`Неплохая попытка! Вы оказались по адресу: ${json.data.address}, промахнулись на ${Math.round(json.data.distance)} метров и заработали ${Math.round(json.data.score)} очков.`,
() => {
- window.location = '/';
+
+ this.setState({
+ isFinished: true
+ })
}
);
}).catch(error => {
</ul>
)}
+
+ {this.state.isFinished && (
+ <div className="Game-controls">
+ <div className="Get-button">
+ <Button onClick={this.startNewGame} size="medium">
+ Начать новую игру
+ </Button>
+ </div>
+ </div>
+ )}
+
+ {!this.state.isFinished && (
+
<div className="Game-controls">
<div className="Get-button">
<Button onClick={this.askTip} size="medium" disabled={this.state.inProcess}>
</Button>
</div>
</div>
+
+ )}
+
</div>
<div className="Game-map">
<div id="map"></div>