From 5a8b13232b13b44fe49a9bb170b6018ffef0f1bf Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Sat, 18 May 2024 20:47:30 -0700 Subject: [PATCH] fix: correct default isOver for des24 schedule --- .../Designathon24/components/Schedule/index.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/pages/Designathons/Designathon24/components/Schedule/index.jsx b/src/app/pages/Designathons/Designathon24/components/Schedule/index.jsx index 3b750858..af491de4 100644 --- a/src/app/pages/Designathons/Designathon24/components/Schedule/index.jsx +++ b/src/app/pages/Designathons/Designathon24/components/Schedule/index.jsx @@ -676,9 +676,15 @@ const DateToggle = ({ handleSelect, defaultDay }) => { ); }; +function addDuration(start, duration) { + return new Date(start.getTime() + duration * 60000); // minutes to milliseconds +} + const ZoomButton = ({ start, duration, eventType, recording }) => { const [isUpcoming, setIsUpcoming] = useState(start > new Date()); - const [isOver, setIsOver] = useState(false); + const [isOver, setIsOver] = useState( + new Date() > addDuration(start, duration), + ); const handleClick = useCallback(() => { if (isOver && recording) { @@ -697,9 +703,7 @@ const ZoomButton = ({ start, duration, eventType, recording }) => { const interval = setInterval(() => { setIsUpcoming(start > new Date()); - const end = new Date(start.getTime() + duration * 60000); // minutes to milliseconds - - setIsOver(new Date() > end); + setIsOver(new Date() > addDuration(start, duration)); }, 1000); return () => clearInterval(interval);