Skip to content

Commit

Permalink
fix: correct default isOver for des24 schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed May 19, 2024
1 parent 665cf63 commit 5a8b132
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 5a8b132

Please sign in to comment.