From e317bbe75a46ef3bf853cf85584bcd22ebaacf23 Mon Sep 17 00:00:00 2001 From: realtradam Date: Sat, 29 Jun 2024 00:20:29 -0400 Subject: add games page + rails auth cleanup --- react-frontend/src/pages/Games.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 react-frontend/src/pages/Games.tsx (limited to 'react-frontend/src/pages') 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([]); + + 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) => ( + + )); + + return ( + <> +
+ { allGames } +
+ + ); +} -- cgit v1.2.3