diff options
Diffstat (limited to 'frontend/src/components/pages/games.js')
| -rw-r--r-- | frontend/src/components/pages/games.js | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/frontend/src/components/pages/games.js b/frontend/src/components/pages/games.js deleted file mode 100644 index 75b5e44..0000000 --- a/frontend/src/components/pages/games.js +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 1 | import React, { useEffect, useState } from 'react'; | ||
| 2 | import { useLocation, Link } from "react-router-dom"; | ||
| 3 | |||
| 4 | import "./games.css" | ||
| 5 | import GameEntry from './game'; | ||
| 6 | |||
| 7 | export default function Games(prop) { | ||
| 8 | const { token } = prop; | ||
| 9 | const [games, setGames] = useState([]); | ||
| 10 | const location = useLocation(); | ||
| 11 | |||
| 12 | useEffect(() => { | ||
| 13 | document.querySelectorAll(".games-page-item-body").forEach((game, index) => { | ||
| 14 | game.innerHTML = ""; | ||
| 15 | }) | ||
| 16 | |||
| 17 | const fetchGames = async () => { | ||
| 18 | try { | ||
| 19 | const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { | ||
| 20 | headers: { | ||
| 21 | 'Authorization': token | ||
| 22 | } | ||
| 23 | }); | ||
| 24 | |||
| 25 | const data = await response.json(); | ||
| 26 | setGames(data.data); | ||
| 27 | pageLoad(); | ||
| 28 | } catch (err) { | ||
| 29 | console.error("Error fetching games:", err); | ||
| 30 | } | ||
| 31 | }; | ||
| 32 | |||
| 33 | fetchGames(); | ||
| 34 | |||
| 35 | function pageLoad() { | ||
| 36 | const loaders = document.querySelectorAll(".loader"); | ||
| 37 | loaders.forEach((loader) => { | ||
| 38 | loader.style.display = "none"; | ||
| 39 | }); | ||
| 40 | } | ||
| 41 | }, [token]); | ||
| 42 | |||
| 43 | return ( | ||
| 44 | <div className='games-page'> | ||
| 45 | <section className='games-page-header'> | ||
| 46 | <span><b>Games list</b></span> | ||
| 47 | </section> | ||
| 48 | |||
| 49 | <section> | ||
| 50 | <div className='games-page-content'> | ||
| 51 | <div className='games-page-item-content'> | ||
| 52 | <div className='loader loader-game'></div> | ||
| 53 | <div className='loader loader-game'></div> | ||
| 54 | {games.map((game, index) => ( | ||
| 55 | <GameEntry gameInfo={game} key={index} /> | ||
| 56 | ))} | ||
| 57 | </div> | ||
| 58 | </div> | ||
| 59 | </section> | ||
| 60 | </div> | ||
| 61 | ); | ||
| 62 | } | ||