From a65d6d9127c3fa7f6a8ecaec5d1ffd1f47c2bc98 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Tue, 3 Sep 2024 00:08:53 +0300 Subject: refactor: port to typescript --- frontend/src/pages/Games.tsx | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 frontend/src/pages/Games.tsx (limited to 'frontend/src/pages/Games.tsx') 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 @@ +import React from 'react'; + +import GameEntry from '../components/GameEntry'; +import { Game } from '../types/Game'; +import { API } from '../api/Api'; +import "../css/Maps.css" + +const Games: React.FC = () => { + const [games, setGames] = React.useState([]); + + const _fetch_games = async () => { + const games = await API.get_games(); + setGames(games); + }; + + const _page_load = () => { + const loaders = document.querySelectorAll(".loader"); + loaders.forEach((loader) => { + (loader as HTMLElement).style.display = "none"; + }); + } + + React.useEffect(() => { + document.querySelectorAll(".games-page-item-body").forEach((game, index) => { + game.innerHTML = ""; + }); + + _fetch_games(); + _page_load(); + }, []); + + return ( +
+
+ Games list +
+ +
+
+
+ {games.map((game, index) => ( + + ))} +
+
+
+
+ ); +}; + +export default Games; -- cgit v1.2.3