-
Logout
+
+ Logout
}
>
diff --git a/pac-man-board-game/ClientApp/src/hooks/useToggle.ts b/pac-man-board-game/ClientApp/src/hooks/useToggle.ts
index b41d4c9..ef437ab 100644
--- a/pac-man-board-game/ClientApp/src/hooks/useToggle.ts
+++ b/pac-man-board-game/ClientApp/src/hooks/useToggle.ts
@@ -1,5 +1,10 @@
import {useState} from "react";
+/**
+ * A hook that returns a boolean value and a function to toggle it. The function can optionally be passed a boolean
+ * @param defaultValue The default value of the boolean, defaults to false.
+ * @returns A tuple containing the boolean value and a function to toggle it.
+ */
export default function useToggle(defaultValue = false): [boolean, (value?: boolean) => void] {
const [value, setValue] = useState(defaultValue);
const toggleValue = (newValue?: boolean) => newValue ? setValue(newValue) : setValue(!value);
diff --git a/pac-man-board-game/ClientApp/src/index.css b/pac-man-board-game/ClientApp/src/index.css
index f9523b4..7d18b5f 100644
--- a/pac-man-board-game/ClientApp/src/index.css
+++ b/pac-man-board-game/ClientApp/src/index.css
@@ -11,6 +11,10 @@
@apply flex justify-center items-center;
}
+.inline-flex-center {
+ @apply inline-flex justify-center items-center;
+}
+
.wh-full {
@apply w-full h-full;
}
diff --git a/pac-man-board-game/ClientApp/src/pages/game.tsx b/pac-man-board-game/ClientApp/src/pages/game.tsx
index 4c13119..844b6bf 100644
--- a/pac-man-board-game/ClientApp/src/pages/game.tsx
+++ b/pac-man-board-game/ClientApp/src/pages/game.tsx
@@ -1,4 +1,4 @@
-import React, {FC, useEffect} from "react";
+import React, {FC} from "react";
import {GameComponent} from "../components/gameComponent";
import {useAtomValue} from "jotai";
import {selectedMapAtom, thisPlayerAtom} from "../utils/state";
@@ -7,12 +7,6 @@ const Game: FC = () => {
const player = useAtomValue(thisPlayerAtom);
const map = useAtomValue(selectedMapAtom);
- useEffect(() => {
- if (!player) {
- window.location.href = "/";
- }
- }, []);
-
if (player && map) {
return
;
} else {
diff --git a/pac-man-board-game/ClientApp/src/pages/lobby.tsx b/pac-man-board-game/ClientApp/src/pages/lobby.tsx
index a2377e5..4fed86e 100644
--- a/pac-man-board-game/ClientApp/src/pages/lobby.tsx
+++ b/pac-man-board-game/ClientApp/src/pages/lobby.tsx
@@ -1,4 +1,4 @@
-import React, {FC, Suspense, useEffect} from "react";
+import React, {FC, Suspense} from "react";
import {atom, useAtomValue} from "jotai";
import {Button} from "../components/button";
import {selectedMapAtom, thisPlayerAtom} from "../utils/state";
@@ -11,7 +11,7 @@ const fetchAtom = atom(async () => {
return await response.json() as Game[];
});
-const LobbyPage: FC = () => { // TODO check if player is defined in storage, if not redirect to login
+const LobbyPage: FC = () => {
const thisPlayer = useAtomValue(thisPlayerAtom);
const navigate = useNavigate();
@@ -25,7 +25,6 @@ const LobbyPage: FC = () => { // TODO check if player is defined in storage, if
if (response.ok) {
const data = await response.json();
- console.debug("Game created: ", data);
navigate("/game/" + data.id)
} else {
const data = await response.text();
@@ -35,10 +34,6 @@ const LobbyPage: FC = () => { // TODO check if player is defined in storage, if
}
- useEffect(() => {
- console.debug(thisPlayer)
- })
-
return (
<>
New game
@@ -60,12 +55,9 @@ const GameTable: FC = ({className}) => {
async function joinGame(gameId: string): Promise {
if (thisPlayer === undefined) throw new Error("Player is undefined");
- console.debug("Joining game " + gameId);
-
const result = await postData("/game/join/" + gameId, {body: thisPlayer});
if (result.ok) {
- console.debug("Joined game " + gameId, await result.text());
navigate("/game/" + gameId);
} else {
console.error("Failed to join game " + gameId, await result.text());