1
1
"use client" ;
2
2
3
- import { useMemo , useState } from "react" ;
3
+ import { useState } from "react" ;
4
+ import Skeleton from "react-loading-skeleton" ;
4
5
5
6
import type { Schema } from "@/amplify/data/resource" ;
6
7
import LoadingRing from "@/components/LoadingRing" ;
@@ -48,36 +49,34 @@ export default function JudgingTable({
48
49
return teams ;
49
50
} ,
50
51
} ) ;
51
- if (
52
- roomIsFetching ||
53
- teamsForRoomIsFetching ||
54
- ! roomData ||
55
- ! teamsForRoomData
56
- ) {
57
- return < div > Loading... </ div > ;
52
+ const isFetching = roomIsFetching || teamsForRoomIsFetching ;
53
+ if ( isFetching || ! roomData || ! teamsForRoomData ) {
54
+ return (
55
+ < div className = "flex flex-1" >
56
+ < Skeleton className = "h-full" containerClassName = "flex-1" />
57
+ </ div >
58
+ ) ;
58
59
}
59
60
60
- const panelData = useMemo ( ( ) => {
61
- return [
62
- {
63
- icon : "/svgs/judging/team_icon.svg" ,
64
- alt : "Teams assigned icon" ,
65
- stat : teamsForRoomData . length ,
66
- text : `Teams Assigned to ${ roomData . name } ` ,
67
- } ,
68
- {
69
- icon : "/svgs/judging/teams_left.svg" ,
70
- alt : "Teams left icon" ,
71
- stat : teamsForRoomData . filter (
72
- async ( team ) =>
73
- ( await team ?. scores ( ) ) ?. data . filter (
74
- ( score ) => score . judgeId === currentUser . username ,
75
- ) . length === 0 ,
76
- ) . length ,
77
- text : "Teams Left To Score" ,
78
- } ,
79
- ] ;
80
- } , [ roomData , teamsForRoomData ] ) ;
61
+ const panelData = [
62
+ {
63
+ icon : "/svgs/judging/team_icon.svg" ,
64
+ alt : "Teams assigned icon" ,
65
+ stat : teamsForRoomData . length ,
66
+ text : `Teams Assigned to ${ roomData . name } ` ,
67
+ } ,
68
+ {
69
+ icon : "/svgs/judging/teams_left.svg" ,
70
+ alt : "Teams left icon" ,
71
+ stat : teamsForRoomData . filter (
72
+ async ( team ) =>
73
+ ( await team ?. scores ( ) ) ?. data . filter (
74
+ ( score ) => score . judgeId === currentUser . username ,
75
+ ) . length === 0 ,
76
+ ) . length ,
77
+ text : "Teams Left To Score" ,
78
+ } ,
79
+ ] ;
81
80
const handleCreateScoreClick = ( teamId : string ) => {
82
81
setSelectedTeamId ( teamId ) ;
83
82
} ;
@@ -89,57 +88,32 @@ export default function JudgingTable({
89
88
setSelectedTeamId ( "" ) ;
90
89
} ;
91
90
92
- const isFetching = roomIsFetching || teamsForRoomIsFetching ;
93
-
94
- const tableHeaders = [
95
- { columnHeader : "Team Name" , className : "w-1/3 rounded-tl-lg" } ,
96
- ...hackathonData . scoringComponents . map ( ( component ) => ( {
97
- columnHeader : component . friendlyName ,
98
- className : "w-fit" ,
99
- } ) ) ,
100
- ...hackathonData . scoringSidepots . map ( ( component ) => ( {
101
- columnHeader : (
102
- < div className = "flex flex-col" >
103
- < p > Sidepot:</ p >
104
- { component . friendlyName }
105
- </ div >
106
- ) ,
107
- className : "w-fit bg-pastel-pink" ,
108
- } ) ) ,
109
- ] ;
110
91
return isFetching ? (
111
- < div
112
- className = {
113
- "flex h-screen w-full items-center justify-center bg-pastel-pink"
114
- }
115
- >
92
+ < div className = "flex size-full flex-1 items-center justify-center bg-pastel-pink" >
116
93
< LoadingRing />
117
94
</ div >
118
95
) : (
119
- < div className = { "flex h-screen justify-center text-blackish" } >
120
- < div className = "mb-4 flex w-full max-w-[1500px] p-6 " >
121
- < div className = "mr-4 flex w-1/4 flex-col space-y-4 " >
96
+ < >
97
+ < div className = "flex w-full flex-col justify-center gap-4 py-6 xl:flex-row " >
98
+ < div className = " flex w-full flex-row gap-4 xl: w-1/4 xl: flex-col" >
122
99
{ panelData . map ( ( item , index ) => (
123
- < div key = { index } className = "h-1/2" >
124
- < StatsPanel
125
- icon = { item . icon }
126
- alt = { item . alt }
127
- stat = { item . stat }
128
- subheader = { item . text }
129
- />
130
- </ div >
100
+ < StatsPanel
101
+ key = { index }
102
+ icon = { item . icon }
103
+ alt = { item . alt }
104
+ stat = { item . stat }
105
+ subheader = { item . text }
106
+ />
131
107
) ) }
132
108
</ div >
133
- < div className = "w-3/4" >
134
- < ScoresTable
135
- tableHeaders = { tableHeaders }
136
- tableData = { teamsForRoomData as Schema [ "Team" ] [ "type" ] [ ] }
137
- onCreateScoreClick = { handleCreateScoreClick }
138
- onEditScoreClick = { handleEditScoreClick }
139
- colorScheme = "pink"
140
- entriesPerPage = { 150 }
141
- />
142
- </ div >
109
+ < ScoresTable
110
+ tableData = { teamsForRoomData as Schema [ "Team" ] [ "type" ] [ ] }
111
+ onCreateScoreClick = { handleCreateScoreClick }
112
+ onEditScoreClick = { handleEditScoreClick }
113
+ colorScheme = "pink"
114
+ entriesPerPage = { 150 }
115
+ hackathonData = { hackathonData }
116
+ />
143
117
</ div >
144
118
{ selectedTeam !== "" && (
145
119
< ModalPopup
@@ -148,6 +122,6 @@ export default function JudgingTable({
148
122
teamId = { selectedTeam }
149
123
/>
150
124
) }
151
- </ div >
125
+ </ >
152
126
) ;
153
127
}
0 commit comments