Refactor event status handling: Remove EventStatus enum from the Prisma schema and update related API routes and UI components to calculate event status dynamically based on event date. This change simplifies event management and enhances data integrity by ensuring status is always derived from the date.

This commit is contained in:
Julien Froidefond
2025-12-10 05:45:25 +01:00
parent fb830c6fcc
commit a69613a232
15 changed files with 167 additions and 298 deletions

View File

@@ -3,6 +3,7 @@ import EventsPageSection from "@/components/EventsPageSection";
import { prisma } from "@/lib/prisma";
import { getBackgroundImage } from "@/lib/preferences";
import { auth } from "@/lib/auth";
import { calculateEventStatus } from "@/lib/eventStatus";
export default async function EventsPage() {
const events = await prisma.event.findMany({
@@ -26,7 +27,9 @@ export default async function EventsPage() {
const initialRegistrations: Record<string, boolean> = {};
if (session?.user?.id) {
const upcomingEvents = events.filter((e) => e.status === "UPCOMING");
const upcomingEvents = events.filter(
(e) => calculateEventStatus(e.date) === "UPCOMING"
);
const eventIds = upcomingEvents.map((e) => e.id);
if (eventIds.length > 0) {