aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/GameEntry.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/GameEntry.tsx')
-rw-r--r--frontend/src/components/GameEntry.tsx32
1 files changed, 9 insertions, 23 deletions
diff --git a/frontend/src/components/GameEntry.tsx b/frontend/src/components/GameEntry.tsx
index 8e58ce9..ced40ee 100644
--- a/frontend/src/components/GameEntry.tsx
+++ b/frontend/src/components/GameEntry.tsx
@@ -1,38 +1,21 @@
1import React from 'react'; 1import React from 'react';
2import { Link } from "react-router-dom"; 2import { Link } from "react-router-dom";
3 3
4import { Game } from '../types/Game'; 4import { Game, GameCategoryPortals } from '../types/Game';
5import "../css/Games.css" 5import "../css/Games.css"
6 6
7import GameCategory from './GameCategory';
8
7interface GameEntryProps { 9interface GameEntryProps {
8 game: Game; 10 game: Game;
9} 11}
10 12
11const GameEntry: React.FC<GameEntryProps> = ({ game }) => { 13const GameEntry: React.FC<GameEntryProps> = ({ game }) => {
14 const [catInfo, setCatInfo] = React.useState<GameCategoryPortals[]>([]);
12 15
13 React.useEffect(() => { 16 React.useEffect(() => {
14 game.category_portals.forEach(catInfo => { 17 setCatInfo(game.category_portals);
15 const itemBody = document.createElement("div"); 18 }, [game.category_portals]);
16 const itemTitle = document.createElement("span");
17 const spacing = document.createElement("br");
18 const itemNum = document.createElement("span");
19
20 itemTitle.innerText = catInfo.category.name;
21 itemNum.innerText = catInfo.portal_count as any as string;
22 itemTitle.classList.add("games-page-item-body-item-title");
23 itemNum.classList.add("games-page-item-body-item-num");
24 itemBody.appendChild(itemTitle);
25 itemBody.appendChild(spacing);
26 itemBody.appendChild(itemNum);
27 itemBody.className = "games-page-item-body-item";
28
29 // itemBody.innerHTML = `
30 // <span className='games-page-item-body-item-title'>${catInfo.category.name}</span><br />
31 // <span className='games-page-item-body-item-num'>${catInfo.portal_count}</span>`
32
33 document.getElementById(`${game.id}`)!.appendChild(itemBody);
34 });
35 }, []);
36 19
37 return ( 20 return (
38 <Link to={"/games/" + game.id}><div className='games-page-item'> 21 <Link to={"/games/" + game.id}><div className='games-page-item'>
@@ -41,6 +24,9 @@ const GameEntry: React.FC<GameEntryProps> = ({ game }) => {
41 <span><b>{game.name}</b></span> 24 <span><b>{game.name}</b></span>
42 </div> 25 </div>
43 <div id={game.id as any as string} className='games-page-item-body'> 26 <div id={game.id as any as string} className='games-page-item-body'>
27 {catInfo.map((cat, index) => {
28 return <GameCategory cat={cat} game={game} key={index}></GameCategory>
29 })}
44 </div> 30 </div>
45 </div></Link> 31 </div></Link>
46 ); 32 );