From 72ea5ba8dfe3259c576452f71396c8520831069d Mon Sep 17 00:00:00 2001 From: chark1es Date: Sat, 1 Mar 2025 01:37:44 -0800 Subject: [PATCH] add checkin boundaries --- .../dashboard/EventsSection/EventCheckIn.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/EventsSection/EventCheckIn.tsx b/src/components/dashboard/EventsSection/EventCheckIn.tsx index bb9b2bd..6601933 100644 --- a/src/components/dashboard/EventsSection/EventCheckIn.tsx +++ b/src/components/dashboard/EventsSection/EventCheckIn.tsx @@ -113,9 +113,16 @@ const EventCheckIn = () => { throw new Error("You have already checked in to this event"); } - // Check if the event hasn't ended yet + // Check if the event is active (has started and hasn't ended yet) + const currentTime = new Date(); + const eventStartDate = new Date(event.start_date); const eventEndDate = new Date(event.end_date); - if (eventEndDate < new Date()) { + + if (eventStartDate > currentTime) { + throw new Error("This event has not started yet"); + } + + if (eventEndDate < currentTime) { throw new Error("This event has already ended"); }