summaryrefslogtreecommitdiffhomepage
path: root/react-frontend/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'react-frontend/src/pages')
-rw-r--r--react-frontend/src/pages/Game.tsx25
-rw-r--r--react-frontend/src/pages/Games.tsx2
2 files changed, 26 insertions, 1 deletions
diff --git a/react-frontend/src/pages/Game.tsx b/react-frontend/src/pages/Game.tsx
new file mode 100644
index 0000000..464176a
--- /dev/null
+++ b/react-frontend/src/pages/Game.tsx
@@ -0,0 +1,25 @@
+import { useState, useEffect } from "react";
+import { useParams } from "react-router-dom";
+import { GameType } from "../components/GameCard";
+
+export default function Games () {
+ const { path_game, path_user } = useParams();
+ const [gameData, setGameData] = useState<GameType>();
+
+ useEffect(() => {
+ const url = `${import.meta.env.VITE_API_TITLE}/api/v1/games/${path_user}/${path_game}`;
+ fetch(url).then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ throw new Error("Network response was not ok.");
+ }).then((response) => setGameData(response)); //.catch(() => navigate("/"));
+ }, [path_game, path_user]);
+
+ return(
+ <>
+ <h1>blah</h1>
+ </>
+ );
+
+}
diff --git a/react-frontend/src/pages/Games.tsx b/react-frontend/src/pages/Games.tsx
index 2a9b23a..b43da06 100644
--- a/react-frontend/src/pages/Games.tsx
+++ b/react-frontend/src/pages/Games.tsx
@@ -15,7 +15,7 @@ export default function Games () {
}, []);
const allGames = games.map((game) => (
- <GameCard link={`/game/${game.titleSlug}`} game={game} key={game.id}/>
+ <GameCard link={`/game/${game.user.user_name}/${game.titleSlug}`} game={game} key={game.id}/>
));
return (