Skip to content

Commit

Permalink
Added group tab to the game page
Browse files Browse the repository at this point in the history
  • Loading branch information
elifkizilky committed Dec 25, 2023
1 parent f076b70 commit 80e2c74
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
35 changes: 35 additions & 0 deletions ludos/frontend/src/components/GroupTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import axios from "axios";
import React, { useEffect, useState } from "react";
import { Grid } from "@mui/material";
import GroupTopic from "./GroupTopic";

function GroupTab(data) {
const [forum, setForum] = useState([]);
useEffect(() => {
const link = `http://${process.env.REACT_APP_API_URL}/group?gameId=${data.id}`;
axios
.get(link, {
headers: {
Authorization: "Bearer " + localStorage.getItem("accessToken"),
},
})
.then((response) => {
console.log(response.data.items);
setForum(response.data.items);
console.log(forum);
})
.catch((error) => {
console.log(error);
});
}, []);

return (
<Grid style={{ display: "grid", gap: "32px" }}>
{forum &&
forum.length > 0 &&
forum.map((topic, key) => <GroupTopic topic={topic} key={key} />)}
</Grid>
);
}

export default GroupTab;
5 changes: 2 additions & 3 deletions ludos/frontend/src/pages/GamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import RelatedGames from "../components/RelatedGamesTab.js";
import EntityTab from "../components/EntityTab.js";
import GameForum from "../components/GameForums.js";
import { useNavigate } from "react-router-dom";
import GroupTab from "../components/GroupTab.js";
import { FaIgloo } from "react-icons/fa";

function GamePage(id) {
Expand Down Expand Up @@ -836,9 +837,7 @@ function GamePage(id) {
</Typography>
</TabPanel>
<TabPanel value="5">
<Typography
style={{ fontSize: "15px", color: "white" }}
></Typography>
<GroupTab id={game.id} />
</TabPanel>
<TabPanel value="6">
<Reviews data={[]} id={game.id} showButtons={auth} />
Expand Down

0 comments on commit 80e2c74

Please sign in to comment.