Refactor event date handling: Update event model to use DateTime type for date fields in Prisma schema. Modify API routes and UI components to ensure consistent date formatting and handling, improving data integrity and user experience across event management and display.

This commit is contained in:
Julien Froidefond
2025-12-10 05:32:23 +01:00
parent fdd860c456
commit 1b07fe8ae5
9 changed files with 160 additions and 49 deletions

View File

@@ -31,7 +31,7 @@ export async function PUT(
}
const updateData: {
date?: string;
date?: Date;
name?: string;
description?: string;
type?: EventType;
@@ -41,7 +41,16 @@ export async function PUT(
maxPlaces?: number | null;
} = {};
if (date !== undefined) updateData.date = date;
if (date !== undefined) {
const eventDate = new Date(date);
if (isNaN(eventDate.getTime())) {
return NextResponse.json(
{ error: "Format de date invalide" },
{ status: 400 }
);
}
updateData.date = eventDate;
}
if (name !== undefined) updateData.name = name;
if (description !== undefined) updateData.description = description;
if (type !== undefined) {