aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/pages/games.js
diff options
context:
space:
mode:
authorWolfboy248 <121288977+Wolfboy248@users.noreply.github.com>2024-07-10 21:51:25 +0200
committerGitHub <noreply@github.com>2024-07-10 22:51:25 +0300
commitcfac59282da55f4791d6352f15887a15e9ff6ec5 (patch)
treebf8cea62f60f9239073a9cf82648d69d1e6b6a1c /frontend/src/components/pages/games.js
parentfeat: return portal counts for each cat in chapter select (#175) (diff)
downloadlphub-cfac59282da55f4791d6352f15887a15e9ff6ec5.tar.gz
lphub-cfac59282da55f4791d6352f15887a15e9ff6ec5.tar.bz2
lphub-cfac59282da55f4791d6352f15887a15e9ff6ec5.zip
Games page, maplist page (#153)
Co-authored-by: Wolfboy248 <105884620+Wolfboy248@users.noreply.github.com>
Diffstat (limited to 'frontend/src/components/pages/games.js')
-rw-r--r--frontend/src/components/pages/games.js58
1 files changed, 58 insertions, 0 deletions
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 @@
1import React, { useEffect, useState } from 'react';
2import { useLocation, Link } from "react-router-dom";
3
4import "./games.css"
5import GameEntry from './game';
6
7export default function Games(prop) {
8 const { token } = prop;
9 const [games, setGames] = useState([]);
10 const location = useLocation();
11
12 useEffect(() => {
13 const fetchGames = async () => {
14 try {
15 const response = await fetch("https://lp.ardapektezol.com/api/v1/games", {
16 headers: {
17 'Authorization': token
18 }
19 });
20
21 const data = await response.json();
22 setGames(data.data);
23 pageLoad();
24 } catch (err) {
25 console.error("Error fetching games:", err);
26 }
27 };
28
29 fetchGames();
30
31 function pageLoad() {
32 const loaders = document.querySelectorAll(".loader");
33 loaders.forEach((loader) => {
34 loader.style.display = "none";
35 });
36 }
37 }, [token]);
38
39 return (
40 <div className='games-page'>
41 <section className='games-page-header'>
42 <span><b>Games list</b></span>
43 </section>
44
45 <section>
46 <div className='games-page-content'>
47 <div className='games-page-item-content'>
48 <div className='loader loader-game'></div>
49 <div className='loader loader-game'></div>
50 {games.map((game, index) => (
51 <GameEntry gameInfo={game} key={index} />
52 ))}
53 </div>
54 </div>
55 </section>
56 </div>
57 );
58}