Skip to content

Commit a6bf25e

Browse files
authored
Merge pull request #37 from codersforcauses/issue-31-Create_match_details_page
Create Match Details Component
2 parents 8459046 + 26b33bb commit a6bf25e

5 files changed

Lines changed: 138 additions & 2 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type MatchDetailsData = {
2+
teamName: string;
3+
opponent: string;
4+
whitePins: number;
5+
penaltyPins: number;
6+
yellowCard: number;
7+
redCard: number;
8+
p1_postion: number;
9+
p2_postion: number;
10+
honorPoint: number;
11+
regularPoint: number;
12+
completedTime: number;
13+
};

client/src/components/ui/Leaderboard/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default function List({ data = [] }) {
130130
// Filter data for the selected group only
131131
const displayData = teamsData.filter((item) => item.group === selectedGroup);
132132

133-
const handleGroupChange = (e) => {
133+
const handleGroupChange = (e: any) => {
134134
setSelectedGroup(e.target.value);
135135
};
136136

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useEffect, useState } from "react";
2+
3+
import { MatchDetailsData } from "../Common/types";
4+
5+
export type MatchDetailsProps = {
6+
matchData: MatchDetailsData[];
7+
header: string[];
8+
};
9+
10+
export default function List({ matchData, header }: MatchDetailsProps) {
11+
return (
12+
<div className="w-full overflow-hidden rounded-lg shadow-lg">
13+
<div className="overflow-x-auto">
14+
<table className="min-w-full bg-white">
15+
<thead>
16+
<tr className="title bg-primary text-center font-bold text-white">
17+
{header.map((row, index) => (
18+
<th key={index} className="px-6 py-4 md:text-lg">
19+
{row}
20+
</th>
21+
))}
22+
</tr>
23+
</thead>
24+
<tbody className="body-sm">
25+
{matchData.map((row, index) => (
26+
<tr
27+
key={index}
28+
className={`border-b border-gray-200 bg-green-50 text-center hover:bg-gray-100`}
29+
>
30+
<td className="px-6 py-4">{row.teamName}</td>
31+
<td className="px-6 py-4">{row.opponent}</td>
32+
<td className="px-6 py-4">{row.whitePins}</td>
33+
<td className="px-6 py-4">{row.penaltyPins}</td>
34+
<td className="px-6 py-4">{row.yellowCard}</td>
35+
<td className="px-6 py-4">{row.redCard}</td>
36+
<td className="px-6 py-4">{row.p1_postion}</td>
37+
<td className="px-6 py-4">{row.p2_postion}</td>
38+
<td className="px-6 py-4">{row.honorPoint}</td>
39+
<td className="px-6 py-4">{row.regularPoint}</td>
40+
<td className="px-6 py-4">{row.completedTime}</td>
41+
</tr>
42+
))}
43+
</tbody>
44+
</table>
45+
</div>
46+
</div>
47+
);
48+
}

client/src/pages/leaderboard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Image from "next/image";
22

3-
import Dropdown from "../components/ui/Leaderboard/Dropdown";
43
import List from "../components/ui/Leaderboard/List";
54

65
export default function LeaderboardPage() {

client/src/pages/matchdetails.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import Image from "next/image";
2+
import { useEffect, useState } from "react";
3+
4+
import { MatchDetailsData } from "../components/ui/Common/types";
5+
import List, { MatchDetailsProps } from "../components/ui/Matchdetails/List";
6+
7+
const columns = [
8+
"Team name",
9+
"Opponent",
10+
"White Pins",
11+
"Penalty Pins",
12+
"Yellow Card",
13+
"Red Card",
14+
"P1 position",
15+
"P2 position",
16+
"Honour Point",
17+
"Regular Point",
18+
"Completed Time",
19+
];
20+
21+
const mockData: MatchDetailsData[] = [
22+
{
23+
teamName: "Red Falcons",
24+
opponent: "Blue Hawks",
25+
whitePins: 2,
26+
penaltyPins: 0,
27+
yellowCard: 1,
28+
redCard: 0,
29+
p1_postion: 1,
30+
p2_postion: 0,
31+
honorPoint: 3,
32+
regularPoint: 3,
33+
completedTime: 240,
34+
},
35+
{
36+
teamName: "Blue Hawks",
37+
opponent: "Red Falcons",
38+
whitePins: 2,
39+
penaltyPins: 0,
40+
yellowCard: 1,
41+
redCard: 0,
42+
p1_postion: 1,
43+
p2_postion: 0,
44+
honorPoint: 3,
45+
regularPoint: 3,
46+
completedTime: 240,
47+
},
48+
];
49+
50+
export default function MatchDetails() {
51+
const [data, setData] = useState(mockData);
52+
53+
useEffect(() => {
54+
// Send API Request
55+
}, []);
56+
57+
return (
58+
<div className="flex min-h-screen flex-col items-center bg-light pt-8">
59+
<div>
60+
<h1 className="title-large text-center font-bold">Match Details</h1>
61+
<div className="relative mx-auto h-[80px] w-[1100px]">
62+
<Image
63+
src="/ProgressBar4.svg"
64+
alt="Progress Bar"
65+
fill
66+
className="object-contain"
67+
priority
68+
/>
69+
</div>
70+
</div>
71+
<div className="relative mx-auto h-[80px] w-[1100px]">
72+
<List header={columns} matchData={data} />
73+
</div>
74+
</div>
75+
);
76+
}

0 commit comments

Comments
 (0)