summaryrefslogtreecommitdiffhomepage
path: root/react-frontend/src/pages
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-06-29 00:20:29 -0400
committerrealtradam <[email protected]>2024-06-29 00:20:29 -0400
commite317bbe75a46ef3bf853cf85584bcd22ebaacf23 (patch)
tree6fbc1d6a210c5eb342ff0c90f46cb57652b8e373 /react-frontend/src/pages
parent101863b2f3c9cce50d1c15bfa5e4dc6971409b35 (diff)
downloadgameHolster-e317bbe75a46ef3bf853cf85584bcd22ebaacf23.tar.gz
gameHolster-e317bbe75a46ef3bf853cf85584bcd22ebaacf23.zip
add games page + rails auth cleanup
Diffstat (limited to 'react-frontend/src/pages')
-rw-r--r--react-frontend/src/pages/Games.tsx28
1 files changed, 28 insertions, 0 deletions
diff --git a/react-frontend/src/pages/Games.tsx b/react-frontend/src/pages/Games.tsx
new file mode 100644
index 0000000..2a9b23a
--- /dev/null
+++ b/react-frontend/src/pages/Games.tsx
@@ -0,0 +1,28 @@
+import { useState, useEffect } from "react";
+import GameCard from "../components/GameCard";
+
+export default function Games () {
+ const [games, setGames] = useState<GameType[]>([]);
+
+ useEffect(() => {
+ const url = `${import.meta.env.VITE_API_TITLE}/api/v1/games`;
+ fetch(url).then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ throw new Error("Network response was not ok.");
+ }).then((response) => setGames(response)); //.catch(() => navigate("/"));
+ }, []);
+
+ const allGames = games.map((game) => (
+ <GameCard link={`/game/${game.titleSlug}`} game={game} key={game.id}/>
+ ));
+
+ return (
+ <>
+ <div className="w-full flex flex-wrap gap-12 justify-center">
+ { allGames }
+ </div>
+ </>
+ );
+}