fix: Incorrect RR host is shown in the email and calendar event for a seated RR event (#21684)
* fix: seated rr event * Update packages/features/bookings/lib/handleNewBooking.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * update * Update handleNewBooking.ts --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
cubic-dev-ai[bot]
parent
13966e0ec8
commit
e82bd45b55
@@ -650,9 +650,31 @@ async function handler(
|
||||
startTime: new Date(dayjs(reqBody.start).utc().format()),
|
||||
status: BookingStatus.ACCEPTED,
|
||||
},
|
||||
select: {
|
||||
userId: true,
|
||||
attendees: { select: { email: true } },
|
||||
},
|
||||
});
|
||||
|
||||
if (booking) isFirstSeat = false;
|
||||
if (booking) {
|
||||
isFirstSeat = false;
|
||||
if (eventType.schedulingType === SchedulingType.ROUND_ROBIN) {
|
||||
const fixedHosts = users.filter((user) => user.isFixed);
|
||||
const originalNonFixedHost = users.find((user) => !user.isFixed && user.id === booking.userId);
|
||||
|
||||
if (originalNonFixedHost) {
|
||||
users = [...fixedHosts, originalNonFixedHost];
|
||||
} else {
|
||||
const attendeeEmailSet = new Set(booking.attendees.map((attendee) => attendee.email));
|
||||
|
||||
// In this case, the first booking user is a fixed host, so the chosen non-fixed host is added as an attendee of the booking
|
||||
const nonFixedAttendeeHost = users.find(
|
||||
(user) => !user.isFixed && attendeeEmailSet.has(user.email)
|
||||
);
|
||||
users = [...fixedHosts, ...(nonFixedAttendeeHost ? [nonFixedAttendeeHost] : [])];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//checks what users are available
|
||||
|
||||
Reference in New Issue
Block a user