NewGame: show selected players in GameBoard #28

Merged
djmil merged 1 commits from #27-selected-players-for-gameboard into main 2023-11-10 12:39:49 +01:00
Showing only changes of commit c08177450a - Show all commits

View File

@ -1,20 +1,27 @@
import './GameBoard.css'
import React from 'react'
import React, { useContext } from 'react';
import { useLocation, matchPath } from 'react-router-dom';
import { GamesContext } from '../../context/games';
import { Color, Player, Board } from '../../components/Checkers';
//import { AppContext } from '../../context/app'
import './GameBoard.css';
export default function GameBoard() {
const games = useContext(GamesContext);
const {pathname} = useLocation();
var whiteName = '';
var blackName = '';
//const [ctx] = React.useContext(AppContext)
if (matchPath('/games/new', pathname)) {
whiteName = games.newGame.whitePlayer;
blackName = games.newGame.blackPlayer;
}
return (
<div className='GameBoard'>
<Player color={Color.white} name={/*ctx.newGame.whitePlayer*/"White player name"} />
<Player color={Color.white} name={whiteName} />
<Board />
<Player color={Color.black} name={/*ctx.newGame.blackPlayer*/"Black player name"} />
<Player color={Color.black} name={blackName} />
</div>
)
}