diff options
Diffstat (limited to 'frontend/src/pages/Games.tsx')
| -rw-r--r-- | frontend/src/pages/Games.tsx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/frontend/src/pages/Games.tsx b/frontend/src/pages/Games.tsx new file mode 100644 index 0000000..e4b33e5 --- /dev/null +++ b/frontend/src/pages/Games.tsx | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | import React from 'react'; | ||
| 2 | |||
| 3 | import GameEntry from '../components/GameEntry'; | ||
| 4 | import { Game } from '../types/Game'; | ||
| 5 | import { API } from '../api/Api'; | ||
| 6 | import "../css/Maps.css" | ||
| 7 | |||
| 8 | const Games: React.FC = () => { | ||
| 9 | const [games, setGames] = React.useState<Game[]>([]); | ||
| 10 | |||
| 11 | const _fetch_games = async () => { | ||
| 12 | const games = await API.get_games(); | ||
| 13 | setGames(games); | ||
| 14 | }; | ||
| 15 | |||
| 16 | const _page_load = () => { | ||
| 17 | const loaders = document.querySelectorAll(".loader"); | ||
| 18 | loaders.forEach((loader) => { | ||
| 19 | (loader as HTMLElement).style.display = "none"; | ||
| 20 | }); | ||
| 21 | } | ||
| 22 | |||
| 23 | React.useEffect(() => { | ||
| 24 | document.querySelectorAll(".games-page-item-body").forEach((game, index) => { | ||
| 25 | game.innerHTML = ""; | ||
| 26 | }); | ||
| 27 | |||
| 28 | _fetch_games(); | ||
| 29 | _page_load(); | ||
| 30 | }, []); | ||
| 31 | |||
| 32 | return ( | ||
| 33 | <div className='games-page'> | ||
| 34 | <section className='games-page-header'> | ||
| 35 | <span><b>Games list</b></span> | ||
| 36 | </section> | ||
| 37 | |||
| 38 | <section> | ||
| 39 | <div className='games-page-content'> | ||
| 40 | <div className='games-page-item-content'> | ||
| 41 | {games.map((game, index) => ( | ||
| 42 | <GameEntry game={game} key={index} /> | ||
| 43 | ))} | ||
| 44 | </div> | ||
| 45 | </div> | ||
| 46 | </section> | ||
| 47 | </div> | ||
| 48 | ); | ||
| 49 | }; | ||
| 50 | |||
| 51 | export default Games; | ||