Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom link #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Zoom link #187

wants to merge 1 commit into from

Conversation

riyeur
Copy link
Contributor

@riyeur riyeur commented Feb 3, 2025

When the admin assigns teams to rooms, a Zoom link is generated by giving access to the app I made on Zoom marketplace to the person's account. This gives us a authorization code which is exchanged for a token, which is then used to create a meeting. Participants don't see the Zoom meeting until 5 minutes before their time.

You'll need to put ZOOM_REDIRECT_URI, ZOOM_CLIENT_ID and ZOOM_CLIENT_SECRET in the env file. These are all on the app on Zoom app marketplace

zoomexample

@riyeur riyeur requested a review from burtonjong February 3, 2025 02:11
@burtonjong
Copy link
Contributor

Looks good just a few things:

  • I am assuming that you created a Zoom app with your own email so we'll have to create one with the CTC email (which is something that I can do, we just replace the keys and clone the permissions)
  • There was one requirement that I had: Will the participant be able to see the link even if it is not close to their dedicated judging time? In your recording I can't really tell because I cant see your local time on your computer

Copy link
Contributor

@burtonjong burtonjong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall just some things to look over - I like how on your api routes you are handling errors and responses very clean very nice

Comment on lines +68 to 84
useEffect(() => {
if (timeSlot) {
const checkTime = () => {
const now = new Date();
const fiveMinutesBefore = new Date(timeSlot);
fiveMinutesBefore.setMinutes(timeSlot.getMinutes() - 5);

setShowZoomLink(now >= fiveMinutesBefore);
};

checkTime();
const interval = setInterval(checkTime, 60000);

return () => clearInterval(interval);
}
}, [timeSlot]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are using dervied state to get the zoomLink, so why not use derived state to also compute setShowZoomLink? This way you subtract a useeffect and usestate hook improving performance

You can do this because of how tanstack query caches the teamroomdataand will update it based on its query key if anything changes

Comment on lines +22 to +38
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get("zoom_token");

if (token) {
setZoomToken(token);
window.history.replaceState({}, document.title, window.location.pathname);

const storedMeetingParams = sessionStorage.getItem("meetingParams");
if (storedMeetingParams) {
const { startDateAndTime, presentationDuration } =
JSON.parse(storedMeetingParams);
createZoomMeeting(token, startDateAndTime, presentationDuration);
sessionStorage.removeItem("meetingParams");
}
}
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storing cookies in session storage isnt the safest and we can avoid this by storing it in http only cookies - this way we dont have to get the token via urlsearchparams

you set up your api auth routes very good but in those routes you can set the http only cookies and then fetch them in the frontend after

https://nextjs.org/docs/app/api-reference/functions/cookies

heres some documentation on how to do it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use NextJS server actions instead? There's a lot of boiler plate with using route handlers.
https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations

@@ -0,0 +1,48 @@
import { NextResponse } from "next/server";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!process.env.ZOOM_CLIENT_SECRET) throw new Error("Missing environment variable ZOOM_CLIENT_SECRET in .env")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!process.env.ZOOM_REDIRECT_URI) throw new Error("Missing environment variable ZOOM_REDIRECT_URI in .env")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw errors if missing envars

<div className="flex flex-col gap-2 p-4 text-start">
<div className="font-medium">Zoom Link: </div>
{showZoomLink && zoomLink ? (
<a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use a tag instead?

@burtonjong
Copy link
Contributor

burtonjong commented Feb 5, 2025

@riyeur listen to justins comments not mine except about the cookies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants