@@ -29,31 +29,47 @@ function TableRow({
2929 components = { } ,
3030 index = 0 ,
3131 total = 0 ,
32+ scoringMetrics,
3233} : {
3334 teamName ?: string ;
3435 components ?: ITeamScores [ string ] [ "components" ] ;
3536 index ?: number ;
3637 total ?: number ;
38+ scoringMetrics : Schema [ "Hackathon" ] [ "type" ] [ "scoringComponents" ] ;
3739} ) {
3840 const bgColor = index % 2 === 1 ? "bg-white" : "bg-dashboard-grey" ;
3941 return (
4042 < tr className = { twMerge ( "border-b" , bgColor ) } >
4143 < td className = "truncate whitespace-nowrap px-6 py-4 font-medium text-dark-grey" >
4244 { teamName }
4345 </ td >
44- { Object . keys ( components ) . map ( ( componentId ) => {
45- return (
46- < td
47- key = { componentId }
48- className = "border-l-2 border-l-white px-6 py-4 text-black"
49- >
50- { components [ componentId ] }
51- </ td >
52- ) ;
53- } ) }
46+ { scoringMetrics
47+ . filter ( ( metric ) => ! metric . isSidepot )
48+ . map ( ( metric ) => {
49+ return (
50+ < td
51+ key = { metric . id }
52+ className = "border-l-2 border-l-white px-6 py-4 text-black"
53+ >
54+ { components [ metric . id ] || 0 }
55+ </ td >
56+ ) ;
57+ } ) }
5458 < td className = "border-l-2 border-l-white px-6 py-4 text-black" >
5559 { total }
5660 </ td >
61+ { scoringMetrics
62+ . filter ( ( metric ) => metric . isSidepot )
63+ . map ( ( metric ) => {
64+ return (
65+ < td
66+ key = { metric . id }
67+ className = "border-l-2 border-l-white px-6 py-4 text-black"
68+ >
69+ { components [ metric . id ] || 0 }
70+ </ td >
71+ ) ;
72+ } ) }
5773 </ tr >
5874 ) ;
5975}
@@ -101,7 +117,11 @@ export default function RankingTable({
101117 Number ( score . score [ scoreComponentId ] )
102118 : score . score [ scoreComponentId ] ;
103119
104- return total + Number ( score . score [ scoreComponentId ] ) ;
120+ // Only add to total if it's not a sidepot
121+ if ( ! metric . isSidepot ) {
122+ return total + Number ( score . score [ scoreComponentId ] ) ;
123+ }
124+ return total ;
105125 } , 0 ) ;
106126
107127 acc [ score . teamId ] . total += teamScore ;
@@ -145,24 +165,25 @@ export default function RankingTable({
145165 < th className = " px-6 py-3" >
146166 < div className = "flex items-center capitalize" > Team</ div >
147167 </ th >
148- { scoringMetrics . map ( ( metric ) => {
149- return (
150- < th key = { metric . id } className = " px-6 py-3" >
151- < div className = "flex items-center capitalize" >
152- { metric . friendlyName }
153- { metric . isSidepot ? " (Sidepot)" : null }
154- < button
155- onClick = { ( ) => {
156- setSortKey ( metric . id ) ;
157- setSortAscending ( ! sortAscending ) ;
158- } }
159- >
160- < FilterIcon />
161- </ button >
162- </ div >
163- </ th >
164- ) ;
165- } ) }
168+ { scoringMetrics
169+ . filter ( ( metric ) => ! metric . isSidepot )
170+ . map ( ( metric ) => {
171+ return (
172+ < th key = { metric . id } className = " px-6 py-3" >
173+ < div className = "flex items-center capitalize" >
174+ { metric . friendlyName }
175+ < button
176+ onClick = { ( ) => {
177+ setSortKey ( metric . id ) ;
178+ setSortAscending ( ! sortAscending ) ;
179+ } }
180+ >
181+ < FilterIcon />
182+ </ button >
183+ </ div >
184+ </ th >
185+ ) ;
186+ } ) }
166187 < th className = " px-6 py-3" >
167188 < div className = "flex items-center capitalize" >
168189 Total
@@ -176,6 +197,25 @@ export default function RankingTable({
176197 </ button >
177198 </ div >
178199 </ th >
200+ { scoringMetrics
201+ . filter ( ( metric ) => metric . isSidepot )
202+ . map ( ( metric ) => {
203+ return (
204+ < th key = { metric . id } className = " px-6 py-3" >
205+ < div className = "flex items-center capitalize" >
206+ { metric . friendlyName } (Sidepot)
207+ < button
208+ onClick = { ( ) => {
209+ setSortKey ( metric . id ) ;
210+ setSortAscending ( ! sortAscending ) ;
211+ } }
212+ >
213+ < FilterIcon />
214+ </ button >
215+ </ div >
216+ </ th >
217+ ) ;
218+ } ) }
179219 </ tr >
180220 </ thead >
181221 < tbody >
@@ -185,6 +225,7 @@ export default function RankingTable({
185225 teamName = { computedScores [ teamId ] . name }
186226 components = { computedScores [ teamId ] . components }
187227 total = { computedScores [ teamId ] . total }
228+ scoringMetrics = { scoringMetrics }
188229 key = { index }
189230 index = { index }
190231 />
0 commit comments