diff --git a/pac-man-board-game/ClientApp/src/AppRoutes.tsx b/pac-man-board-game/ClientApp/src/AppRoutes.tsx index 3fe1d1d..e3a3b31 100644 --- a/pac-man-board-game/ClientApp/src/AppRoutes.tsx +++ b/pac-man-board-game/ClientApp/src/AppRoutes.tsx @@ -1,6 +1,7 @@ import React from "react"; import {Counter} from "./pages/counter"; import Home from "./pages/home"; +import Game from "./pages/game"; const AppRoutes = [ { @@ -11,6 +12,10 @@ const AppRoutes = [ path: "/counter", element: }, + { + path: "/game", + element: , + }, ]; export default AppRoutes; diff --git a/pac-man-board-game/ClientApp/src/pages/game.tsx b/pac-man-board-game/ClientApp/src/pages/game.tsx new file mode 100644 index 0000000..decafd5 --- /dev/null +++ b/pac-man-board-game/ClientApp/src/pages/game.tsx @@ -0,0 +1,13 @@ +import React from "react"; +import {GameComponent} from "../components/gameComponent"; +import {useLocation} from "react-router-dom"; +import Player from "../game/player"; + +const Game: Component = () => { + const location = useLocation(); + const player = location.state as Player; + + return ; +}; + +export default Game; diff --git a/pac-man-board-game/ClientApp/src/pages/home.tsx b/pac-man-board-game/ClientApp/src/pages/home.tsx index c0903b5..83341df 100644 --- a/pac-man-board-game/ClientApp/src/pages/home.tsx +++ b/pac-man-board-game/ClientApp/src/pages/home.tsx @@ -1,42 +1,36 @@ -import React, {FormEvent, useRef, useState} from "react"; -import {GameComponent} from "../components/gameComponent"; +import React, {useRef} from "react"; import Player from "../game/player"; import Input from "../components/input"; import Dropdown from "../components/dropdown"; import {Colour, getColours} from "../game/colour"; +import {useNavigate} from "react-router-dom"; const Home: Component = () => { - const [player, setPlayer] = useState(); const input = useRef(null); const dropdown = useRef(null); + const navigate = useNavigate(); - function formHandler(e: FormEvent): void { - e.preventDefault(); + function formHandler(): void { if (!input.current || !dropdown.current) return; - setPlayer(new Player({ + const player = new Player({ Name: input.current.value, Colour: dropdown.current.value as Colour, - })); + }); + navigate("/game", {state: player}); } return ( <>

Pac-Man The Board Game

- { - player ? - /*TODO move to own page*/ - - : -
-

Enter your name:

- -

Choose a colour:

- -
- - - } +
+

Enter your name:

+ +

Choose a colour:

+ +
+ + ); };