Files
bam/lib/signup-time-check.ts
Felix Schulze 358dc77e5a
Some checks failed
Check / Lint and Check (push) Failing after 30s
disable sign-up on event day
2025-07-15 16:28:02 +02:00

24 lines
719 B
TypeScript

import eventConfig from "@/event-dates.json";
export function isSignupBlocked(): { blocked: boolean; message?: string } {
const now = new Date();
const currentDate = now.toISOString().split("T")[0]; // YYYY-MM-DD format
const currentTime = now.toTimeString().slice(0, 5); // HH:MM format
// Check if today is an event date
const isEventDay = eventConfig.eventDates.includes(currentDate);
if (isEventDay) {
// Check if current time is after the cutoff time (default 15:00 / 3pm)
const cutoffTime = eventConfig.cutoffTime || "15:00";
if (currentTime >= cutoffTime) {
return {
blocked: true,
message: eventConfig.message,
};
}
}
return { blocked: false };
}