mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* 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 <[email protected]> * Update roundRobinManualReassignment.ts --------- Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]>
37 lines
1.1 KiB
TypeScript
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;
|
|
}
|