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.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/frontend/src/components/GameEntry.tsx b/frontend/src/components/GameEntry.tsx
new file mode 100644
index 0000000..8e58ce9
--- /dev/null
+++ b/frontend/src/components/GameEntry.tsx
@@ -0,0 +1,49 @@
1import React from 'react';
2import { Link } from "react-router-dom";
3
4import { Game } from '../types/Game';
5import "../css/Games.css"
6
7interface GameEntryProps {
8 game: Game;
9}
10
11const GameEntry: React.FC<GameEntryProps> = ({ game }) => {
12
13 React.useEffect(() => {
14 game.category_portals.forEach(catInfo => {
15 const itemBody = document.createElement("div");
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
37 return (
38 <Link to={"/games/" + game.id}><div className='games-page-item'>
39 <div className='games-page-item-header'>
40 <div style={{ backgroundImage: `url(${game.image})` }} className='games-page-item-header-img'></div>
41 <span><b>{game.name}</b></span>
42 </div>
43 <div id={game.id as any as string} className='games-page-item-body'>
44 </div>
45 </div></Link>
46 );
47};
48
49export default GameEntry;