diff --git a/src/components/Ready.js b/src/components/Ready.js index 4ca22e7..2f9238d 100644 --- a/src/components/Ready.js +++ b/src/components/Ready.js @@ -1,5 +1,4 @@ import { Component } from "react"; -import request from "../scripts/requests"; class Ready extends Component { @@ -10,19 +9,6 @@ class Ready extends Component { disabled: true, parent: props.parent } - this.state.parent.ready = this; - this.click = this.click.bind(this); - } - - click() { - request("place_ships", { - game_id: this.state.parent.getGameId(), - token: localStorage.getItem('token'), - field: this.state.parent.field.getLine() - }, () => this.setState({ - text: "Ждем ответа соперника", - disabled: true - })) } update() { @@ -41,7 +27,7 @@ class Ready extends Component { } render() { - return + return } } diff --git a/src/screens/NewGame.js b/src/screens/NewGame.js index 1e837a0..06f4424 100644 --- a/src/screens/NewGame.js +++ b/src/screens/NewGame.js @@ -18,7 +18,9 @@ class NewGame extends Component { constructor(props) { super(props); this.state = { - ok: false + ok: false, + readyText: "Заполни поле чтобы начать", + readyDisabled: true } this.queryParams = new URLSearchParams(window.location.search); } @@ -26,22 +28,31 @@ class NewGame extends Component { update() { const line = this.field.getLine(); request("check_field_correct", {field: line}, (response) => { - this.setState({ok: response.correct}); if (response.correct) { - this.ready.setState({ - text: "Я готов", - disabled: false + this.setState({ + readyText: "Я готов", + readyDisabled: false }) } else { - this.ready.setState({ - text: "Расставь корабли чтобы активировать", - disabled: true + this.setState({ + readyText: "Заполни поле чтобы начать", + readyDisabled: true }) } - this.ready.setState({ok: this.state.ok}); }); } + clickReady() { + request("place_ships", { + game_id: this.getGameId(), + token: localStorage.getItem('token'), + field: this.field.getLine() + }, (response) => this.setState({ + readyText: "Ждем ответа соперника", + readyDisabled: true + })) + } + render() { return (
Ссылка для подключения
-