Enhance event model and management: Add new fields for room, time, and maxPlaces to the Event model in Prisma schema. Update API routes and UI components to support these fields, improving event details and user interaction in event management and registration processes.
This commit is contained in:
@@ -16,7 +16,7 @@ export async function PUT(
|
||||
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
const { date, name, description, type, status } = body;
|
||||
const { date, name, description, type, status, room, time, maxPlaces } = body;
|
||||
|
||||
// Vérifier que l'événement existe
|
||||
const existingEvent = await prisma.event.findUnique({
|
||||
@@ -36,6 +36,9 @@ export async function PUT(
|
||||
description?: string;
|
||||
type?: EventType;
|
||||
status?: EventStatus;
|
||||
room?: string | null;
|
||||
time?: string | null;
|
||||
maxPlaces?: number | null;
|
||||
} = {};
|
||||
|
||||
if (date !== undefined) updateData.date = date;
|
||||
@@ -59,6 +62,9 @@ export async function PUT(
|
||||
}
|
||||
updateData.status = status as EventStatus;
|
||||
}
|
||||
if (room !== undefined) updateData.room = room || null;
|
||||
if (time !== undefined) updateData.time = time || null;
|
||||
if (maxPlaces !== undefined) updateData.maxPlaces = maxPlaces ? parseInt(maxPlaces) : null;
|
||||
|
||||
const event = await prisma.event.update({
|
||||
where: { id },
|
||||
|
||||
@@ -22,6 +22,9 @@ export async function GET() {
|
||||
description: true,
|
||||
type: true,
|
||||
status: true,
|
||||
room: true,
|
||||
time: true,
|
||||
maxPlaces: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
@@ -40,6 +43,9 @@ export async function GET() {
|
||||
description: event.description,
|
||||
type: event.type,
|
||||
status: event.status,
|
||||
room: event.room,
|
||||
time: event.time,
|
||||
maxPlaces: event.maxPlaces,
|
||||
createdAt: event.createdAt.toISOString(),
|
||||
updatedAt: event.updatedAt.toISOString(),
|
||||
registrationsCount: event._count.registrations,
|
||||
@@ -64,7 +70,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { date, name, description, type, status } = body;
|
||||
const { date, name, description, type, status, room, time, maxPlaces } = body;
|
||||
|
||||
if (!date || !name || !description || !type || !status) {
|
||||
return NextResponse.json(
|
||||
@@ -95,6 +101,9 @@ export async function POST(request: Request) {
|
||||
description,
|
||||
type: type as EventType,
|
||||
status: status as EventStatus,
|
||||
room: room || null,
|
||||
time: time || null,
|
||||
maxPlaces: maxPlaces ? parseInt(maxPlaces) : null,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user