Files
calendar/packages/features/ee/round-robin/utils/getDestinationCalendar.ts
T
6df994389b feat: round robin handover to specific host (#17215)
* frontend dialog

* handler + fe calling handler

* reafctors + start work on fix hosts tests

* restore rr

* update tests + fixing types

* use a getRRHostsToReasign handler + error handle + i18n

* typefixes

* assert type

* fix: adds missing translation

* Update roundRobinManualReassignment.ts

* Update roundRobinManualReassignment.ts

* Update apps/web/components/dialog/ReassignDialog.tsx

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>

* Update roundRobinManualReassignment.ts

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
2024-10-21 19:52:09 -07:00

37 lines
1.1 KiB
TypeScript

import type { getEventTypesFromDB } from "@calcom/features/bookings/lib/handleNewBooking/getEventTypesFromDB";
import { prisma } from "@calcom/prisma";
import type { DestinationCalendar } from "@calcom/prisma/client";
import type { BookingSelectResult } from "./bookingSelect";
export async function getDestinationCalendar({
eventType,
booking,
newUserId,
hasOrganizerChanged,
}: {
eventType?: Awaited<ReturnType<typeof getEventTypesFromDB>>;
booking?: BookingSelectResult;
newUserId?: number;
hasOrganizerChanged: boolean;
}): Promise<DestinationCalendar[] | undefined> {
if (eventType?.destinationCalendar) {
return [eventType.destinationCalendar];
}
if (hasOrganizerChanged && newUserId) {
const newUserDestinationCalendar = await prisma.destinationCalendar.findFirst({
where: {
userId: newUserId,
},
});
if (newUserDestinationCalendar) {
return [newUserDestinationCalendar];
}
} else {
if (booking?.user?.destinationCalendar) return [booking.user.destinationCalendar];
}
return undefined;
}