Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions amplify/data/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const schema = a
id: a.id().required(),
time: a.datetime().required(),
zoomLink: a.string().required(),
duration: a.integer(),
teamId: a.id().required(),
roomId: a.id().required(),
team: a.belongsTo("Team", "teamId"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const handler: Schema["ScheduleTeamsAndJudges"]["functionHandler"] =
time: currTime.toISOString(),
roomId: roomIds[column],
zoomLink: "",
duration: presentationDuration,
},
},
}),
Expand Down
3 changes: 3 additions & 0 deletions amplify/graphql/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export type TeamRoom = {
time: string;
updatedAt: string;
zoomLink: string;
duration?: number | null;
};

export type Room = {
Expand Down Expand Up @@ -493,6 +494,7 @@ export type CreateTeamRoomInput = {
teamId: string;
time: string;
zoomLink: string;
duration?: number | null;
};

export type ModelUserConditionInput = {
Expand Down Expand Up @@ -623,6 +625,7 @@ export type UpdateTeamRoomInput = {
teamId?: string | null;
time?: string | null;
zoomLink?: string | null;
duration?: number | null;
};

export type UpdateUserInput = {
Expand Down
1 change: 1 addition & 0 deletions amplify/graphql/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export const createTeamRoom = /* GraphQL */ `mutation CreateTeamRoom(
time
updatedAt
zoomLink
duration
__typename
}
}
Expand Down
2 changes: 2 additions & 0 deletions amplify/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const getTeamRoom = /* GraphQL */ `query GetTeamRoom($id: ID!) {
time
updatedAt
zoomLink
duration
__typename
}
}
Expand Down Expand Up @@ -427,6 +428,7 @@ export const listTeamRooms = /* GraphQL */ `query ListTeamRooms(
time
updatedAt
zoomLink
duration
__typename
}
nextToken
Expand Down
2 changes: 1 addition & 1 deletion src/app/judging/assigned-teams/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const AssignedTeamsPage = () => {
return <div className="p-6">You have no room assigned yet.</div>;

return (
<div className="p-6">
<div className="h-dvh p-6">
<h1 className="mb-4 text-2xl font-semibold">
Your Teams: {roomData?.name ?? ""}
</h1>
Expand Down
5 changes: 4 additions & 1 deletion src/components/admin/Judging/JudgingSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ export default function JudgingSchedule() {
.join(", ") || "No Team Name",
room_id: teamRoom.roomId,
start: new Date(teamRoom.time),
end: new Date(new Date(teamRoom.time).getTime() + 15 * 60 * 1000),
end: new Date(
new Date(teamRoom.time).getTime() +
(teamRoom.duration ?? 10) * 60 * 1000,
),
zoomLink: teamRoom.zoomLink,
}))
: [];
Expand Down
12 changes: 8 additions & 4 deletions src/components/admin/Judging/JudgingTimeline.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { Scheduler } from "@aldabil/react-scheduler";
import RedirectIcon from "../../RedirectIcon";

type JudgeRoom = {
roomName: string;
Expand Down Expand Up @@ -48,11 +49,14 @@ export default function JudgingTimeline({
deletable={false}
viewerExtraComponent={(fields, event) => {
return (
<p>
<a
href={event.zoomLink}
className="inline-flex flex-row items-center gap-1 text-dark-green hover:underline"
>
{/* Replace with actual zoom link not the room id */}
<span className="font-bold">Zoom Link:</span>{" "}
<a href={event.zoomLink}>{event.title}</a>
</p>
<span className="font-bold">Zoom Link</span>
<RedirectIcon />
</a>
);
}}
/>
Expand Down
26 changes: 18 additions & 8 deletions src/components/admin/Judging/RoomAssigner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useState } from "react";
import { createZoomMeeting } from "@/app/zoom/actions";

Check warning on line 4 in src/components/admin/Judging/RoomAssigner.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint Scanning

'createZoomMeeting' is defined but never used

export default function RoomAssigner({
judgingScheduleMutation,
Expand All @@ -21,6 +21,8 @@
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);

const ZOOM_LINK = process.env.NEXT_PUBLIC_ZOOM_LINK;

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
};
Expand Down Expand Up @@ -48,14 +50,22 @@
presentationDuration: Number(duration),
});

const meetingData = await createZoomMeeting(
formattedDate,
Number(duration),
);
// dynamically create zoom links
// const meetingData = await createZoomMeeting(
// formattedDate,
// Number(duration),
// );

// setMeetingLink(meetingData.join_url);
// updateTeamRoomsWithZoomLink();

// temporary hardcoded zoom link
if (!ZOOM_LINK) {
throw new Error("Zoom link missing in .env.");
}

setMeetingLink(meetingData.join_url);
updateTeamRoomsWithZoomLink(meetingData.join_url);
updateTeamRoomsWithZoomLink(ZOOM_LINK);
} catch (err) {

Check warning on line 68 in src/components/admin/Judging/RoomAssigner.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint Scanning

'err' is defined but never used
setError("Failed to create Zoom meeting.");
} finally {
setLoading(false);
Expand All @@ -72,7 +82,7 @@
>
<div className="flex w-full flex-col gap-4 md:flex-row">
<div className="flex w-full flex-col gap-2 md:w-1/4">
<label htmlFor="numberOfRooms">Enter Number of Room:</label>
<label htmlFor="numberOfRooms">Enter Number of Rooms:</label>
<input
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"
type="number"
Expand All @@ -82,7 +92,7 @@
/>
</div>
<div className="flex w-full flex-col gap-2 md:w-1/4">
<label htmlFor="duration">Enter Judging Duration:</label>
<label htmlFor="duration">Enter Duration (minutes):</label>
<input
id="duration"
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"
Expand Down
56 changes: 12 additions & 44 deletions src/components/judging/Schedule/schedule.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use client";

import { generateClient } from "aws-amplify/api";
import { useState } from "react";

Check warning on line 4 in src/components/judging/Schedule/schedule.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint Scanning

'useState' is defined but never used
import { type Schema } from "@/amplify/data/resource";
import JudgingTimeline from "@/components/admin/Judging/JudgingTimeline";
import KevinLoadingRing from "@/components/KevinLoadingRing";
import { useQuery } from "@tanstack/react-query";

const client = generateClient<Schema>();
Expand Down Expand Up @@ -94,62 +95,29 @@
.join(", ") || "No Team Name",
room_id: teamRoom.roomId,
start: new Date(teamRoom.time),
end: new Date(new Date(teamRoom.time).getTime() + 15 * 60 * 1000),
end: new Date(
new Date(teamRoom.time).getTime() +
(teamRoom.duration ?? 10) * 60 * 1000,
),
zoomLink: teamRoom.zoomLink,
}))
: [];

// State to manage the filter (all teams or assigned teams)
const [filter, setFilter] = useState<"all" | "assigned">("all");

// Filtered events based on the selected filter
const filteredEvents =
filter === "all"
? judgingEvents
: judgingEvents.filter((event) =>
judgeData?.some((judge) => judge.JUDGE_roomId === event.room_id),
);

return isLoading ? (
<div className=" mt-48 flex h-full items-center justify-center text-awesomer-purple">
Loading schedule...
<div className="flex h-screen items-center justify-center">
<KevinLoadingRing />
</div>
) : (
<div className="mt-8 flex flex-col items-center">
{/* Filter Buttons */}
<div className="mb-6 flex space-x-4">
<button
onClick={() => setFilter("all")}
className={`rounded px-4 py-2 ${
filter === "all"
? "bg-awesomer-purple text-white"
: "bg-dashboard-grey"
}`}
>
All Teams
</button>
<button
onClick={() => setFilter("assigned")}
className={`rounded px-4 py-2 ${
filter === "assigned"
? "bg-awesomer-purple text-white"
: "bg-dashboard-grey"
}`}
>
Assigned Teams
</button>
<div className="text-6xl text-awesomer-purple">Judging Schedule</div>
</div>

{/* Schedule Display */}
<div className="w-full max-w-[1000px] rounded-md border border-awesomer-purple bg-light-grey p-4 text-lg text-black">
{filteredEvents.length > 0 ? (
<JudgingTimeline
judgeRooms={judgeRooms}
judgingEvents={filteredEvents}
/>
) : (
<div className="flex justify-center">Schedule not made yet</div>
)}
<JudgingTimeline
judgeRooms={judgeRooms}
judgingEvents={judgingEvents}
/>
</div>
</div>
);
Expand Down
Loading