import axios from 'axios'; import { 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 { IssueList } from '../components/issues'; 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'; import { ArticleMeta, getStaticProps as getBlogPage, RenderedArticle } from './blog/[post]'; // edit this to change the post displayed on the home page var posts = ['beta']; function LoginOrRegisterBox() { return
Log in of maak een account aan om toegang tot meer functies te krijgen
; } 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(props: { posts: Array<{ props: { content: string; meta: ArticleMeta; }; }>; }) { 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 && }
{props.posts.map(post => { return ; })}

Github Issues

; } export function getStaticProps() { var postsContent = []; posts.forEach(post => { postsContent.push(getBlogPage({ params: { post } })); }); var staticProps = { props: { posts: postsContent } }; return staticProps; }