File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { type UserResponse } from "@/data/schema" ;
2- import { usersResponseSchema } from "@/data/schema" ;
3- import axios from "./axiosConfig" ;
41import { z } from "zod" ;
5- export const leaderboardSchema = z . object ( {
6- ID : z . string ( ) ,
7- team_id : z . string ( ) ,
2+ import axios from "./axiosConfig" ;
3+ export const scoreSchema = z . object ( {
84 team_name : z . string ( ) ,
95 design : z . number ( ) ,
106 implementation : z . number ( ) ,
@@ -14,15 +10,21 @@ export const leaderboardSchema = z.object({
1410 comment : z . string ( ) ,
1511 total_score : z . number ( ) ,
1612} ) ;
13+ export const leaderboardUserSchema = z . object ( {
14+ ID : z . string ( ) ,
15+ team_id : z . string ( ) ,
16+ team_name : z . string ( ) ,
17+ rounds : z . array ( scoreSchema ) ,
18+ overall_total : z . number ( ) ,
19+ } ) ;
1720
18- export type Leaderboard = z . infer < typeof leaderboardSchema > ;
21+ export type Leaderboard = z . infer < typeof leaderboardUserSchema > ;
1922
2023export const leaderBoardResponseSchema = z . object ( {
2124 status : z . string ( ) ,
2225 message : z . string ( ) ,
2326 data : z . object ( {
24- message : z . string ( ) . optional ( ) ,
25- users : z . array ( leaderboardSchema ) . nullable ( ) ,
27+ users : z . array ( leaderboardUserSchema ) . nullable ( ) ,
2628 } ) ,
2729} ) ;
2830export type LeaderboardResponse = z . infer < typeof leaderBoardResponseSchema > ;
Original file line number Diff line number Diff line change @@ -26,30 +26,46 @@ export default function ViewScores({ row }: { row: Row<Leaderboard> }) {
2626 < Label className = "font-semibold" > Team Name:</ Label > { " " }
2727 { row . original . team_name }
2828 </ 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 >
29+ { row . original . rounds . map ( ( round , index ) => {
30+ const {
31+ design,
32+ implementation,
33+ innovation,
34+ presentation,
35+ teamwork,
36+ total_score,
37+ } = round ;
38+
39+ return (
40+ < div key = { index } className = "border border-black p-2 overflow-y-auto" >
41+ < div > Round { index } score: </ div >
42+ < div >
43+ < Label className = "font-semibold" > Design:</ Label > { " " }
44+ { design }
45+ </ div >
46+ < div >
47+ < Label className = "font-semibold" > Implementation:</ Label > { " " }
48+ { implementation }
49+ </ div >
50+ < div >
51+ < Label className = "font-semibold" > Innovation:</ Label > { " " }
52+ { innovation }
53+ </ div >
54+ < div >
55+ < Label className = "font-semibold" > Presentation:</ Label > { " " }
56+ { presentation }
57+ </ div >
58+ < div >
59+ < Label className = "font-semibold" > Teamwork:</ Label > { " " }
60+ { teamwork }
61+ </ div >
62+ < div >
63+ < Label className = "font-semibold" > Total Score:</ Label > { " " }
64+ { total_score }
65+ </ div >
66+ </ div >
67+ ) ;
68+ } ) }
5369 </ CardContent >
5470 </ Card >
5571 </ DialogDescription >
Original file line number Diff line number Diff line change 11"use client" ;
2- import { type leaderboardSchema } from "@/api/leaderboard" ;
2+ import { type leaderboardUserSchema } from "@/api/leaderboard" ;
33import { type ColumnDef } from "@tanstack/react-table" ;
44import { type z } from "zod" ;
55import ViewScores from "../ViewScores" ;
66import ChangeRound from "../changeRound" ;
77
8- const columns : ColumnDef < z . infer < typeof leaderboardSchema > > [ ] = [
8+ const columns : ColumnDef < z . infer < typeof leaderboardUserSchema > > [ ] = [
99 {
1010 accessorKey : "team_name" ,
1111 header : "Team Name" ,
1212 } ,
1313 {
14- accessorKey : "total_score " ,
14+ accessorKey : "rounds " ,
1515 header : "Scores" ,
1616 cell : ( { row } ) => < ViewScores row = { row } /> ,
1717 } ,
1818 {
19- accessorKey : "total_score " ,
19+ accessorKey : "overall_total " ,
2020 header : "Final Score" ,
21- }
22- ,
21+ } ,
22+
2323 {
2424 accessorKey : "ID" ,
2525 header : "Set Round" ,
2626 cell : ( { row } ) => < ChangeRound row = { row } /> ,
27-
28- }
27+ } ,
2928] ;
3029
31- export default columns
30+ export default columns ;
You can’t perform that action at this time.
0 commit comments