From 441e6e4a8e107172d2743afb58071a4edfc853b6 Mon Sep 17 00:00:00 2001 From: Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:19:24 +0200 Subject: [#189 + #193] Games page fix --- frontend/src/components/GameCategory.tsx | 24 ++++++++++++++++++++++++ frontend/src/components/GameEntry.tsx | 32 +++++++++----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 frontend/src/components/GameCategory.tsx (limited to 'frontend/src') diff --git a/frontend/src/components/GameCategory.tsx b/frontend/src/components/GameCategory.tsx new file mode 100644 index 0000000..3291e09 --- /dev/null +++ b/frontend/src/components/GameCategory.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Link } from "react-router-dom"; + +import { Game, GameCategoryPortals } from '../types/Game'; +import "../css/Games.css" + +interface GameCategoryProps { + game: Game; + cat: GameCategoryPortals; +} + +const GameCategory: React.FC = ({cat, game}) => { + return ( + = ({ game }) => { + const [catInfo, setCatInfo] = React.useState([]); React.useEffect(() => { - game.category_portals.forEach(catInfo => { - const itemBody = document.createElement("div"); - const itemTitle = document.createElement("span"); - const spacing = document.createElement("br"); - const itemNum = document.createElement("span"); - - itemTitle.innerText = catInfo.category.name; - itemNum.innerText = catInfo.portal_count as any as string; - itemTitle.classList.add("games-page-item-body-item-title"); - itemNum.classList.add("games-page-item-body-item-num"); - itemBody.appendChild(itemTitle); - itemBody.appendChild(spacing); - itemBody.appendChild(itemNum); - itemBody.className = "games-page-item-body-item"; - - // itemBody.innerHTML = ` - // ${catInfo.category.name}
- // ${catInfo.portal_count}` - - document.getElementById(`${game.id}`)!.appendChild(itemBody); - }); - }, []); + setCatInfo(game.category_portals); + }, [game.category_portals]); return (
@@ -41,6 +24,9 @@ const GameEntry: React.FC = ({ game }) => { {game.name}
+ {catInfo.map((cat, index) => { + return + })}
); -- cgit v1.2.3