From e1978a9b80f3f7f5a36ca4af5f6df62f494a0d6d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 20 Feb 2021 13:03:04 +0100 Subject: /game/random endpoint --- pages/game.tsx | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'pages') diff --git a/pages/game.tsx b/pages/game.tsx index 57eca5e..5f610f8 100644 --- a/pages/game.tsx +++ b/pages/game.tsx @@ -98,7 +98,7 @@ class VoerGame extends Component { maxWidth: "100vh", margin: "0 auto" }}> - this.move(m % this.width + 1)}/> + this.move(m % this.width + 1)} active={this.state.outcome == -1}/> @@ -133,11 +133,11 @@ function GameOutcomeDialog(props: { 6 Optimale zetten
0 Blunders

} - } style={{ + { false && } style={{ float: "none", marginTop: 24, padding: "12px 32px" - }}/> + }}/> } } @@ -168,13 +168,35 @@ var InviteButtonLabelStyle: CSSProperties = { userSelect: "none" } -export default function GamePage() { - return ( -
+export default class GamePage extends Component { + constructor(props: {}) { + super(props); + + if (typeof window === "undefined") return; + if (document.cookie.includes("token") == false) return; + axios.request({ + method: "get", + url: `/api/user/info`, + headers: {"content-type": "application/json"} + }) + .then(request => this.setState({ userID: request.data.id })) + .catch(() => {}); + } + + state: { + userID: string; + gameID: string; + } = { + userID: "", + gameID: "", + } + + render() { + return
- {false && + {true &&
-
+

{this.state.gameID}

}
- ); + } } -- cgit v1.2.3