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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user