Compare commits
1 commit
a36ea0cb6b
...
5e9f8b59a4
Author | SHA1 | Date | |
---|---|---|---|
5e9f8b59a4 |
2 changed files with 27 additions and 13 deletions
|
@ -229,6 +229,23 @@ export const PATCH = auth(async (req, { params }) => {
|
|||
participants,
|
||||
} = data.data;
|
||||
|
||||
if (participants !== undefined)
|
||||
for (const participant of participants) {
|
||||
await prisma.meetingParticipant.upsert({
|
||||
where: {
|
||||
meeting_id_user_id: {
|
||||
user_id: participant,
|
||||
meeting_id: eventID,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
user_id: participant,
|
||||
meeting_id: eventID,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
}
|
||||
|
||||
const updatedEvent = await prisma.meeting.update({
|
||||
where: {
|
||||
id: eventID,
|
||||
|
@ -240,18 +257,16 @@ export const PATCH = auth(async (req, { params }) => {
|
|||
end_time,
|
||||
location,
|
||||
status,
|
||||
participants: !participants
|
||||
? undefined
|
||||
: {
|
||||
deleteMany: {
|
||||
user_id: {
|
||||
notIn: participants,
|
||||
},
|
||||
},
|
||||
create: participants.map((participant) => ({
|
||||
user_id: participant,
|
||||
})),
|
||||
},
|
||||
participants:
|
||||
participants !== undefined
|
||||
? {
|
||||
deleteMany: {
|
||||
user_id: {
|
||||
notIn: participants || [],
|
||||
},
|
||||
},
|
||||
}
|
||||
: {},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
|
|
@ -113,7 +113,6 @@ export const createEventSchema = zod
|
|||
// ----------------------------------------
|
||||
export const updateEventSchema = zod
|
||||
.object({
|
||||
id: eventIdSchema,
|
||||
title: eventTitleSchema.optional(),
|
||||
description: eventDescriptionSchema.optional(),
|
||||
start_time: eventStartTimeSchema.optional(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue