Skip to content

Commit 2b4e12f

Browse files
added leaderboard tanstack table
1 parent 81fb3e9 commit 2b4e12f

2 files changed

Lines changed: 65 additions & 4 deletions

File tree

src/components/ViewScores.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Leaderboard } from "@/api/leaderboard";
2+
import { Row } from "@tanstack/react-table";
3+
import React from "react";
4+
import {
5+
Dialog,
6+
DialogContent,
7+
DialogDescription,
8+
DialogHeader,
9+
DialogTitle,
10+
DialogTrigger,
11+
} from "@/components/ui/dialog";
12+
import { Card, CardContent } from "./ui/card";
13+
import { Label } from "@radix-ui/react-dropdown-menu";
14+
15+
export default function ViewScores({ row }: { row: Row<Leaderboard> }) {
16+
return (
17+
<Dialog>
18+
<DialogTrigger>View Scores</DialogTrigger>
19+
<DialogContent>
20+
<DialogHeader>
21+
<DialogTitle>Here are the scores: </DialogTitle>
22+
<DialogDescription>
23+
<Card>
24+
<CardContent className="space-y-2">
25+
<div>
26+
<Label className="font-semibold">Team Name:</Label>{" "}
27+
{row.original.team_name}
28+
</div>
29+
<div>
30+
<Label className="font-semibold">Design:</Label>{" "}
31+
{row.original.design}
32+
</div>
33+
<div>
34+
<Label className="font-semibold">Implementation:</Label>{" "}
35+
{row.original.implementation}
36+
</div>
37+
<div>
38+
<Label className="font-semibold">Innovation:</Label>{" "}
39+
{row.original.innovation}
40+
</div>
41+
<div>
42+
<Label className="font-semibold">Presentation:</Label>{" "}
43+
{row.original.presentation}
44+
</div>
45+
<div>
46+
<Label className="font-semibold">Teamwork:</Label>{" "}
47+
{row.original.teamwork}
48+
</div>
49+
<div>
50+
<Label className="font-semibold">Total Score:</Label>{" "}
51+
{row.original.total_score}
52+
</div>
53+
</CardContent>
54+
</Card>
55+
</DialogDescription>
56+
</DialogHeader>
57+
</DialogContent>
58+
</Dialog>
59+
);
60+
}

src/components/columns/LeaderBoardCol.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
import { leaderboardSchema } from "@/api/leaderboard";
33
import { ColumnDef } from "@tanstack/react-table";
44
import { z } from "zod";
5+
import ViewScores from "../ViewScores";
56

67
export const columns: ColumnDef<z.infer<typeof leaderboardSchema>>[] = [
7-
{
8-
accessorKey: "team_id",
9-
header: "Year",
10-
},
118
{
129
accessorKey: "team_name",
1310
header: "Team Name",
@@ -17,4 +14,8 @@ export const columns: ColumnDef<z.infer<typeof leaderboardSchema>>[] = [
1714
header: "Scores",
1815
cell: ({ row }) => <ViewScores row={row} />,
1916
},
17+
{
18+
accessorKey: "total_score",
19+
header: "Final Score",
20+
},
2021
];

0 commit comments

Comments
 (0)