From 453a45d980b6dd16bdaefb9567bc416582c0f3cc Mon Sep 17 00:00:00 2001 From: djmil Date: Fri, 10 Nov 2023 12:39:49 +0100 Subject: [PATCH] NewGame: show selected players in GameBoard (#28) Reviewed-on: http://192.168.8.55:3000/HQLAx/CordaCheckers/pulls/28 --- webapp/src/container/games/GameBoard.jsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/webapp/src/container/games/GameBoard.jsx b/webapp/src/container/games/GameBoard.jsx index b5b93fe..ea73a33 100644 --- a/webapp/src/container/games/GameBoard.jsx +++ b/webapp/src/container/games/GameBoard.jsx @@ -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 (
- + - +
) } \ No newline at end of file