feat(api): add participant management endpoints and update event response structure

This commit is contained in:
Dominik 2025-06-14 19:09:48 +02:00
parent a0e9aca808
commit ea12d37120
Signed by: dominik
GPG key ID: 06A4003FC5049644
4 changed files with 786 additions and 4 deletions

View file

@ -107,8 +107,11 @@ export const GET = auth(async (req, { params }) => {
name: event.organizer.name,
},
participants: event.participants.map((participant) => ({
id: participant.user.id,
name: participant.user.name,
user: {
id: participant.user.id,
name: participant.user.name,
},
status: participant.status,
})),
},
},
@ -411,10 +414,40 @@ export const PATCH = auth(async (req, { params }) => {
id: eventID,
},
data: updateData,
include: {
organizer: true,
participants: {
include: {
user: true,
},
},
},
});
return NextResponse.json(
{ success: true, event: updatedEvent },
{
success: true,
event: {
id: updatedEvent.id,
title: updatedEvent.title,
description: updatedEvent.description,
start_time: updatedEvent.start_time,
end_time: updatedEvent.end_time,
status: updatedEvent.status,
location: updatedEvent.location,
organizer: {
id: updatedEvent.organizer_id,
name: dbUser.name,
},
participants: updatedEvent.participants.map((participant) => ({
user: {
id: participant.user.id,
name: participant.user.name,
},
status: participant.status,
})),
},
},
{ status: 200 },
);
});