Skip to content

Commit 7479dce

Browse files
fisayoadabsfionaa-truongburtonjongskand088anthonyych4n
authored
Sidepot Totals and Clockcount down working (#265)
Co-authored-by: Fiona Truong <151110138+fionaa-truong@users.noreply.github.com> Co-authored-by: burtonjong <burtonjong05@gmail.com> Co-authored-by: Burton Jong <108391733+burtonjong@users.noreply.github.com> Co-authored-by: simar kandola <simarkandola51@gmail.com> Co-authored-by: Anthony <88424536+anthonyych4n@users.noreply.github.com> Co-authored-by: Fiona <fionat119@icloud.com>
1 parent b0cf292 commit 7479dce

File tree

12 files changed

+124
-90
lines changed

12 files changed

+124
-90
lines changed

amplify/data/resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const schema = a
131131
id: a.id().required(),
132132
time: a.datetime().required(),
133133
zoomLink: a.string().required(),
134+
duration: a.integer(),
134135
teamId: a.id().required(),
135136
roomId: a.id().required(),
136137
team: a.belongsTo("Team", "teamId"),

amplify/function/BusinessLogic/ScheduleTeamsAndJudges/handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const handler: Schema["ScheduleTeamsAndJudges"]["functionHandler"] =
118118
time: currTime.toISOString(),
119119
roomId: roomIds[column],
120120
zoomLink: "",
121+
duration: presentationDuration,
121122
},
122123
},
123124
}),

amplify/graphql/API.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export type TeamRoom = {
122122
time: string;
123123
updatedAt: string;
124124
zoomLink: string;
125+
duration?: number | null;
125126
};
126127

127128
export type Room = {
@@ -493,6 +494,7 @@ export type CreateTeamRoomInput = {
493494
teamId: string;
494495
time: string;
495496
zoomLink: string;
497+
duration?: number | null;
496498
};
497499

498500
export type ModelUserConditionInput = {
@@ -623,6 +625,7 @@ export type UpdateTeamRoomInput = {
623625
teamId?: string | null;
624626
time?: string | null;
625627
zoomLink?: string | null;
628+
duration?: number | null;
626629
};
627630

628631
export type UpdateUserInput = {

amplify/graphql/mutations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ export const createTeamRoom = /* GraphQL */ `mutation CreateTeamRoom(
342342
time
343343
updatedAt
344344
zoomLink
345+
duration
345346
__typename
346347
}
347348
}

amplify/graphql/queries.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export const getTeamRoom = /* GraphQL */ `query GetTeamRoom($id: ID!) {
186186
time
187187
updatedAt
188188
zoomLink
189+
duration
189190
__typename
190191
}
191192
}
@@ -427,6 +428,7 @@ export const listTeamRooms = /* GraphQL */ `query ListTeamRooms(
427428
time
428429
updatedAt
429430
zoomLink
431+
duration
430432
__typename
431433
}
432434
nextToken

src/components/LandingPage/HeroSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default async function HeroSection() {
1919
return <div>Hackathon hasn't been created yet</div>;
2020
}
2121

22-
const eventStartDate = new Date(hackathonData[0].startDate);
23-
const eventEndDate = new Date(hackathonData[0].endDate);
22+
const eventStartDate = new Date(2025, 10, 8, 9, 0, 0); // Month is 0-indexed → 10 = November
23+
const eventEndDate = new Date(2025, 10, 9, 17, 0, 0); // Example: Sunday 5 PM
2424

2525
return (
2626
<div className="relative flex flex-col items-center justify-center md:px-8 md:py-16 lg:px-32">

src/components/admin/Judging/JudgingSchedule.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ export default function JudgingSchedule() {
168168
.join(", ") || "No Team Name",
169169
room_id: teamRoom.roomId,
170170
start: new Date(teamRoom.time),
171-
end: new Date(new Date(teamRoom.time).getTime() + 15 * 60 * 1000),
171+
end: new Date(
172+
new Date(teamRoom.time).getTime() +
173+
(teamRoom.duration ?? 10) * 60 * 1000,
174+
),
172175
zoomLink: teamRoom.zoomLink,
173176
}))
174177
: [];

src/components/admin/Judging/JudgingTimeline.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { Scheduler } from "@aldabil/react-scheduler";
4+
import RedirectIcon from "../../RedirectIcon";
45

56
type JudgeRoom = {
67
roomName: string;
@@ -48,11 +49,14 @@ export default function JudgingTimeline({
4849
deletable={false}
4950
viewerExtraComponent={(fields, event) => {
5051
return (
51-
<p>
52+
<a
53+
href={event.zoomLink}
54+
className="inline-flex flex-row items-center gap-1 text-dark-green hover:underline"
55+
>
5256
{/* Replace with actual zoom link not the room id */}
53-
<span className="font-bold">Zoom Link:</span>{" "}
54-
<a href={event.zoomLink}>{event.title}</a>
55-
</p>
57+
<span className="font-bold">Zoom Link</span>
58+
<RedirectIcon />
59+
</a>
5660
);
5761
}}
5862
/>

src/components/admin/Judging/RoomAssigner.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default function RoomAssigner({
2121
const [loading, setLoading] = useState<boolean>(false);
2222
const [error, setError] = useState<string | null>(null);
2323

24+
const ZOOM_LINK = process.env.NEXT_PUBLIC_ZOOM_LINK;
25+
2426
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
2527
setInputValue(e.target.value);
2628
};
@@ -48,13 +50,21 @@ export default function RoomAssigner({
4850
presentationDuration: Number(duration),
4951
});
5052

51-
const meetingData = await createZoomMeeting(
52-
formattedDate,
53-
Number(duration),
54-
);
53+
// dynamically create zoom links
54+
// const meetingData = await createZoomMeeting(
55+
// formattedDate,
56+
// Number(duration),
57+
// );
58+
59+
// setMeetingLink(meetingData.join_url);
60+
// updateTeamRoomsWithZoomLink();
61+
62+
// temporary hardcoded zoom link
63+
if (!ZOOM_LINK) {
64+
throw new Error("Zoom link missing in .env.");
65+
}
5566

56-
setMeetingLink(meetingData.join_url);
57-
updateTeamRoomsWithZoomLink(meetingData.join_url);
67+
updateTeamRoomsWithZoomLink(ZOOM_LINK);
5868
} catch (err) {
5969
setError("Failed to create Zoom meeting.");
6070
} finally {
@@ -72,7 +82,7 @@ export default function RoomAssigner({
7282
>
7383
<div className="flex w-full flex-col gap-4 md:flex-row">
7484
<div className="flex w-full flex-col gap-2 md:w-1/4">
75-
<label htmlFor="numberOfRooms">Enter Number of Room:</label>
85+
<label htmlFor="numberOfRooms">Enter Number of Rooms:</label>
7686
<input
7787
className="flex items-center justify-between rounded-lg border-2 border-awesome-purple bg-white p-4 font-bold text-black duration-100 hover:border-awesomer-purple active:border-awesome-purple active:text-black"
7888
type="number"
@@ -82,7 +92,7 @@ export default function RoomAssigner({
8292
/>
8393
</div>
8494
<div className="flex w-full flex-col gap-2 md:w-1/4">
85-
<label htmlFor="duration">Enter Judging Duration:</label>
95+
<label htmlFor="duration">Enter Duration (minutes):</label>
8696
<input
8797
id="duration"
8898
className="flex items-center justify-between rounded-lg border-2 border-awesome-purple bg-white p-4 font-bold text-black duration-100 hover:border-awesomer-purple active:border-awesome-purple active:text-black"

src/components/admin/RankingTable.tsx

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)