feat: provide option to allow rescheduling with the same round-robin host (#15132)

* feat: provide option to allow rescheduling with the same round-robin
host

* update

* fix type error

* fix and update

* fix type error

* update

* remove

* Update getEventTypesFromDB.ts

* add test

* small fix

* fix requested changes
This commit is contained in:
Anik Dhabal Babu authored and GitHub committed 2024-08-12 15:03:50 +02:00
1 parent 24936d8b7b
commit 848bcbfb8f
17 files changed
+232 -8

No files matched your search

@@ -175,6 +175,7 @@ export async function getEventType(
periodEndDate: true,
onlyShowFirstAvailableSlot: true,
periodCountCalendarDays: true,
rescheduleWithSameRoundRobinHost: true,
periodDays: true,
metadata: true,
schedule: {
@@ -436,7 +437,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
let teamMember: string | undefined;
const hosts =
let hosts =
eventType.hosts?.length && eventType.schedulingType
? eventType.hosts
: eventType.users.map((user) => {
@@ -446,6 +447,25 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
};
});
if (
input.rescheduleUid &&
eventType.rescheduleWithSameRoundRobinHost &&
eventType.schedulingType === SchedulingType.ROUND_ROBIN
) {
const originalRescheduledBooking = await prisma.booking.findFirst({
where: {
uid: input.rescheduleUid,
status: {
in: [BookingStatus.ACCEPTED],
},
},
select: {
userId: true,
},
});
hosts = hosts.filter((host) => host.user.id === originalRescheduledBooking?.userId || 0);
}
let usersWithCredentials = hosts.map(({ isFixed, user }) => ({ isFixed, ...user }));
if (eventType.schedulingType === SchedulingType.ROUND_ROBIN && input.bookerEmail) {