Skip to content

Commit

Permalink
fix: 🐛 Fix card color bug
Browse files Browse the repository at this point in the history
  • Loading branch information
elvisscochito committed Sep 11, 2023
1 parent 6c5c5b0 commit 9e0d095
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions frontend/src/components/MeetingCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const MeetingCard = ({ datetime, currentDate, setCurrentDate, room, rooms, setMe
}
}, [meeting, meeting.start, meeting.end, datetime]); */

useLayoutEffect(() => {
/* useLayoutEffect(() => {
const meetingStart = new Date(meeting.start).toDateString();
const dateTimeDate = new Date(datetime).toDateString();
Expand Down Expand Up @@ -79,7 +79,26 @@ const MeetingCard = ({ datetime, currentDate, setCurrentDate, room, rooms, setMe
// Si no es el mismo día, establece el estado como "upcoming"
setMeetingStatus("ended");
}
}, [meeting, meeting.start, meeting.end, datetime]);
}, [meeting, meeting.start, meeting.end, datetime]); */

useLayoutEffect(() => {
const calculateMeetingStatus = () => {
const meetingStart = new Date(meeting.start);
const meetingEnd = new Date(meeting.end);
const now = new Date();

if (now >= meetingStart && now <= meetingEnd) {
return "ongoing";
} else if (now > meetingEnd) {
return "ended";
} else {
return "upcoming";
}
};

const status = calculateMeetingStatus();
setMeetingStatus(status);
}, [meeting, meeting.start, meeting.end]);

return (
<>
Expand Down

0 comments on commit 9e0d095

Please sign in to comment.