From cfac59282da55f4791d6352f15887a15e9ff6ec5 Mon Sep 17 00:00:00 2001 From: Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:51:25 +0200 Subject: Games page, maplist page (#153) Co-authored-by: Wolfboy248 <105884620+Wolfboy248@users.noreply.github.com> --- frontend/src/components/pages/games.js | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 frontend/src/components/pages/games.js (limited to 'frontend/src/components/pages/games.js') diff --git a/frontend/src/components/pages/games.js b/frontend/src/components/pages/games.js new file mode 100644 index 0000000..8c27151 --- /dev/null +++ b/frontend/src/components/pages/games.js @@ -0,0 +1,58 @@ +import React, { useEffect, useState } from 'react'; +import { useLocation, Link } from "react-router-dom"; + +import "./games.css" +import GameEntry from './game'; + +export default function Games(prop) { + const { token } = prop; + const [games, setGames] = useState([]); + const location = useLocation(); + + useEffect(() => { + const fetchGames = async () => { + try { + const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { + headers: { + 'Authorization': token + } + }); + + const data = await response.json(); + setGames(data.data); + pageLoad(); + } catch (err) { + console.error("Error fetching games:", err); + } + }; + + fetchGames(); + + function pageLoad() { + const loaders = document.querySelectorAll(".loader"); + loaders.forEach((loader) => { + loader.style.display = "none"; + }); + } + }, [token]); + + return ( +