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

feat: add zoom recording buttons to des24 #122

Merged
merged 1 commit into from
May 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const FridaySchedule = () => {
</div>

<ZoomButton
date={new Date(2024, 4, 17, 16, 30)}
start={new Date(2024, 4, 17, 16, 30)}
duration={60}
eventType={"ceremony"}
/>
</div>
Expand Down Expand Up @@ -119,7 +120,10 @@ const FridaySchedule = () => {
<p className={cn.host}>Hosted by Commit the Change</p>
</div>

<ZoomButton date={new Date(2024, 4, 17, 18, 40)} />
<ZoomButton
start={new Date(2024, 4, 17, 18, 40)}
duration={45}
/>
</div>

<div className={cn.important}>9:00 PM | Venue Closes</div>
Expand Down Expand Up @@ -155,7 +159,10 @@ const FridaySchedule = () => {
</p>
</div>

<ZoomButton date={new Date(2024, 4, 17, 21, 40)} />
<ZoomButton
start={new Date(2024, 4, 17, 21, 40)}
duration={55}
/>
</div>
</div>
);
Expand Down Expand Up @@ -234,7 +241,10 @@ const SaturdaySchedule = () => {
<p className={cn.host}>Hosted by Wenting Zhu</p>
</div>

<ZoomButton date={new Date(2024, 4, 18, 11, 30)} />
<ZoomButton
start={new Date(2024, 4, 18, 11, 30)}
duration={45}
/>
</div>

<div className={cn.event}>
Expand Down Expand Up @@ -361,7 +371,10 @@ const SaturdaySchedule = () => {
</p>
</div>

<ZoomButton date={new Date(2024, 4, 18, 15, 45)} />
<ZoomButton
start={new Date(2024, 4, 18, 15, 45)}
duration={45}
/>
</div>

<div className={cn.event}>
Expand Down Expand Up @@ -415,7 +428,10 @@ const SaturdaySchedule = () => {
</p>
</div>

<ZoomButton date={new Date(2024, 4, 18, 19, 10)} />
<ZoomButton
start={new Date(2024, 4, 18, 19, 10)}
duration={45}
/>
</div>

<div className={cn.important}>9:00 PM | Venue Closes</div>
Expand Down Expand Up @@ -542,7 +558,10 @@ const SundaySchedule = () => {
</p>
</div>

<ZoomButton date={new Date(2024, 4, 19, 13, 30)} />
<ZoomButton
start={new Date(2024, 4, 19, 13, 30)}
duration={90}
/>
</div>

<div className={cn.event}>
Expand Down Expand Up @@ -585,7 +604,8 @@ const SundaySchedule = () => {
</div>

<ZoomButton
date={new Date(2024, 4, 19, 17, 0)}
start={new Date(2024, 4, 19, 17, 0)}
duration={60}
eventType={"ceremony"}
/>
</div>
Expand Down Expand Up @@ -656,41 +676,58 @@ const DateToggle = ({ handleSelect, defaultDay }) => {
);
};

const ZoomButton = ({ date, eventType }) => {
const [isUpcoming, setIsUpcoming] = useState(date > new Date());
const ZoomButton = ({ start, duration, eventType, recording }) => {
const [isUpcoming, setIsUpcoming] = useState(start > new Date());
const [isOver, setIsOver] = useState(false);

const handleClick = useCallback(() => {
if (!isUpcoming) {
if (isOver && recording) {
window.open(recording, "_blank");
} else if (!isUpcoming) {
window.open(
eventType === "ceremony"
? "https://uci.zoom.us/j/92344530635"
: "https://uci.zoom.us/j/94772751120",
"_blank",
);
}
}, [eventType, isUpcoming]);
}, [eventType, isOver, isUpcoming, recording]);

useEffect(() => {
const interval = setInterval(() => {
setIsUpcoming(date > new Date());
setIsUpcoming(start > new Date());

const end = new Date(start.getTime() + duration * 60000); // minutes to milliseconds

setIsOver(new Date() > end);
}, 1000);

return () => clearInterval(interval);
}, [date]);
}, [duration, start]);

const buttonClassName = useMemo(() => {
return clsx(cn.zoomButton, isUpcoming ? cn.beforeDate : cn.afterDate);
}, [isUpcoming]);

const buttonText = useMemo(() => {
return isUpcoming ? "Zoom Link Posted Soon" : "Join Zoom";
}, [isUpcoming]);
return isOver
? "Zoom Recording"
: isUpcoming
? "Zoom Link Posted Soon"
: "Join Zoom";
}, [isOver, isUpcoming]);

const ariaLabel = useMemo(() => {
return isUpcoming
? "Zoom link will be posted soon"
: "Join Zoom meeting in a new tab";
}, [isUpcoming]);
return isOver
? "Watch Zoom recording in a new tab"
: isUpcoming
? "Zoom link will be posted soon"
: "Join Zoom meeting in a new tab";
}, [isOver, isUpcoming]);

if (isOver && !recording) {
return null;
}

return (
<button
Expand Down