import axios from 'axios'; import { CSSProperties, useContext, useEffect, useState } from 'react'; import { userGames, userGameTotals, userInfo } from '../api/api'; import { Footer } from '../components/footer'; import { SocketContext } from '../components/socketContext'; import { AccountAvatar } from '../components/account'; import { NavBar } from '../components/navbar'; import { CenteredPage, PageTitle } from '../components/page'; import RecentGames from '../components/recentGames'; import { Button, Vierkant } from '../components/ui'; import ExtensionIcon from '@material-ui/icons/Extension'; import VideogameAssetIcon from '@material-ui/icons/VideogameAsset'; import { mdiRobotExcited } from '@mdi/js'; import Icon from '@mdi/react'; var GameModeIconStyle: CSSProperties = { fontSize: 64, width: 64, height: 64, display: 'inline-block', position: 'absolute', top: 24, left: '50%', transform: 'translateX(-50%)', }; var GameModeTextStyle: CSSProperties = { whiteSpace: 'nowrap', display: 'inline-block', position: 'absolute', bottom: 24, left: '50%', transform: 'translateX(-50%)', userSelect: 'none', fontWeight: 500, }; var SquareSize: CSSProperties = { width: 90, height: 90, }; var LoginOrRegisterBoxStyle: CSSProperties = { verticalAlign: 'top', height: `calc(${SquareSize.height}px + 24px * 2)`, width: '100%', maxWidth: `calc(100% - ${SquareSize.width}px - 12px * 2 - 24px * 2)`, }; var InnerLoginOrRegisterBoxStyle: CSSProperties = { position: 'relative', width: '100%', height: '100%', }; function LoginOrRegisterBox() { return
Log in of maak een account aan om je scores op te slaan en toegang te krijgen tot meer functies
; } function AccountBox(props: { info: userInfo; sumGameInfo: userGameTotals; }) { return

{props.info?.username}

Score: {props.info?.rating}

{props.sumGameInfo?.win} W / {props.sumGameInfo?.lose} V / {props.sumGameInfo?.draw} G

; } export default function HomePage() { var server = typeof window === 'undefined'; var loggedIn = !server && document.cookie.includes('token'); var { io } = useContext(SocketContext); useEffect(() => { io.on('connect', () => { console.log('gert'); }); }, []); var [userInfo, setUserInfo] = useState(); var [gameInfo, setGameInfo] = useState(); useEffect(() => { (async () => { if (!loggedIn) return; var userInfoReq = await axios.request({ method: 'get', url: `/api/user/info`, headers: { 'content-type': 'application/json' }, }); setUserInfo(userInfoReq.data); })(); }, []); useEffect(() => { (async () => { if (!loggedIn) return; var userGamesReq = await axios.request({ method: 'get', url: `/api/user/games`, headers: { 'content-type': 'application/json' }, }); setGameInfo(userGamesReq.data); })(); }, []); return
4 op een rij
Nieuw spel
{false && Puzzels
} {false && Tegen computer
} {loggedIn ? : }
{loggedIn && }

Nieuws ofzo

Chess.com heeft heel veel troep waar niemand naar kijkt

; }