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