From 49531187459e5d22adcfdb857377a887699e2a18 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Wed, 19 Jan 2022 17:50:36 -0800 Subject: [PATCH] sorting nice and next one going one text very nice --- components/Dashboard/Rooms.tsx | 26 ++++++++++++++++++++++++ components/Modals/CreateOrUpdateRoom.tsx | 1 + 2 files changed, 27 insertions(+) diff --git a/components/Dashboard/Rooms.tsx b/components/Dashboard/Rooms.tsx index baf33ef..febcf4f 100644 --- a/components/Dashboard/Rooms.tsx +++ b/components/Dashboard/Rooms.tsx @@ -200,6 +200,21 @@ export default function DashboardRoom() { ); }); + var relativeTimeNextMeeting = ""; + + // go through scheduled and find the first one coming up + if (scheduled && scheduled.length > 0) { + const firstOneInFuture = scheduled.find( + (room) => moment(room.scheduledDateTime.toDate()).diff(today) > 0 + ); + + if (firstOneInFuture) { + const meetingDatetime: Date = + firstOneInFuture.scheduledDateTime.toDate(); + relativeTimeNextMeeting = moment(meetingDatetime).fromNow(); + } + } + return ( <> @@ -226,6 +241,17 @@ export default function DashboardRoom() { roomType={RoomType.scheduled} /> + {relativeTimeNextMeeting ? ( + + {"You have your next one "}{" "} + + {relativeTimeNextMeeting} + + + ) : ( + <> + )} +
{scheduled.map((room) => ( ) : (