aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-21 09:30:40 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-21 09:30:40 +0100
commit96f56b2154195191132fb43c5b27f0a7c2ce1bb6 (patch)
treea698c06ab5beac7bc65fb22529f7134aa2533b9c /pages
parente1978a9b80f3f7f5a36ca4af5f6df62f494a0d6d (diff)
working game-id's
Diffstat (limited to 'pages')
-rw-r--r--pages/game.tsx56
-rw-r--r--pages/index.tsx3
2 files changed, 30 insertions, 29 deletions
diff --git a/pages/game.tsx b/pages/game.tsx
index 5f610f8..6890a7e 100644
--- a/pages/game.tsx
+++ b/pages/game.tsx
@@ -17,7 +17,8 @@ import LinkRoundedIcon from '@material-ui/icons/LinkRounded';
import RefreshIcon from '@material-ui/icons/Refresh';
interface VoerGameProps {
-
+ gameID: string;
+ token: string;
}
class VoerGame extends Component<VoerGameProps> {
@@ -71,22 +72,12 @@ class VoerGame extends Component<VoerGameProps> {
};
board = [...Array(this.width * this.height)].map(() => 0);
- userID = "";
move(column: number) {
- if(this.state.userID == "") {
- axios.request<userInfo>({
- method: "get",
- url: `/api/user/info`,
- headers: {"content-type": "application/json"}
- })
- .then(request => this.setState({ userID: request.data.id }))
- .catch(() => {});
- }
this.io.emit("newMove", {
move: column,
- token: cookies.load("token"),
- gameID: "fortnite"
+ token: this.props.token,
+ game_id: this.props.gameID
});
}
@@ -172,30 +163,33 @@ export default class GamePage extends Component {
constructor(props: {}) {
super(props);
- if (typeof window === "undefined") return;
- if (document.cookie.includes("token") == false) return;
- axios.request<userInfo>({
- method: "get",
- url: `/api/user/info`,
- headers: {"content-type": "application/json"}
- })
- .then(request => this.setState({ userID: request.data.id }))
- .catch(() => {});
+ /* if (typeof window === "undefined") return; */
+ /* if (document.cookie.includes("token") == false) return; */
+ /* axios.request<userInfo>({ */
+ /* method: "get", */
+ /* url: `/api/user/info`, */
+ /* headers: {"content-type": "application/json"} */
+ /* }) */
+ /* .then(request => this.setState({ */
+ /* user: request.data, */
+ /* token: cookies.load("token") */
+ /* })) */
+ /* .catch(() => {}); */
}
state: {
- userID: string;
gameID: string;
+ token: string;
} = {
- userID: "",
gameID: "",
+ token: "",
}
render() {
return <div>
<NavBar/>
<CenteredPage width={900} style={{ height: "100vh" }}>
- <VoerGame/>
+ <VoerGame gameID={this.state.gameID} token={this.state.token}/>
{true && <DialogBox title="Nieuw spel">
<CurrentGameSettings/>
<div style={{
@@ -209,9 +203,12 @@ export default class GamePage extends Component {
method: "post",
url: "/api/game/random",
headers: {"content-type": "application/json"},
- data: { user_id: this.state.userID }
+ data: {}
})
- .then(request => this.setState({ gameID: request.data.id }))
+ .then(request => this.setState({
+ gameID: request.data.id,
+ token: cookies.load("token")
+ }))
.catch(() => {});
}}>
<WifiTetheringRoundedIcon style={{
@@ -229,7 +226,10 @@ export default class GamePage extends Component {
</Button>
</div>
<SearchBar label="Zoeken in vriendenlijst"/>
- <p>{this.state.gameID}</p>
+ <code>
+ {this.state.gameID}
+ {this.state.token}
+ </code>
</DialogBox>}
</CenteredPage>
</div>
diff --git a/pages/index.tsx b/pages/index.tsx
index 84f08b8..f341c35 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -61,7 +61,8 @@ function LoginOrRegisterBox() {
display: "inline-block",
position: "absolute",
fontSize: 14,
- left: 0, right: 0, top: 0
+ left: 0, right: 0, top: 0,
+ margin: "0 100px"
}}>Log in of maak een account aan om je scores op te slaan en toegang te krijgen tot meer functies</span>
<div style={{
display: "grid",