feat(api): add participant management endpoints and update event response structure
This commit is contained in:
parent
a0e9aca808
commit
ea12d37120
4 changed files with 786 additions and 4 deletions
|
@ -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 },
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue