refactor: Refactor seats logic (#12905)
* Refactor createBooking * Type fix * Abstract handleSeats * Create Invitee type * Create OrganizerUser type * Abstract addVideoCallDataToEvt * Abstract createLoggerWithEventDetails * Abstract `handleAppStatus` from handler * Create ReqAppsStatus type * Move `deleteMeeting` and `getCalendar` * Set parameters for `handleSeats` * Typescript refactor * Change function params from req * Type fix * Move handleSeats * Abstract lastAttendeeDeleteBooking * Create function for rescheduling seated events * Fix imports on reschedule seats function * Fix imports * Import handleSeats function * Fix rescheduleUid type * Refactor owner reschedule to new time slot * Refactor combine two booking times together * Reschedule as an attendee * Refactor createNewSeat * Remove old handleSeats * Remove lastAttendeeDeleteBooking from handleNewBooking * Test for new attendee right params are passed * Unit test params for reschedule * Typo fix * Clean up * Create new seat test * Test when attendee already signs up for booking * Type fix * Test reschedule move attendee to existing booking * On reschedule create new booking * Test on last attendee cancel booking * Owner reschedule to new time slot * Owner rescheduling, merge two bookings together * Test: when merging more than available seats, then fail * Test: fail when event is full * Remove duplicate E2E tests * Clean up * Rename `addVideoCallDataToEvt` to `addVideoCallDataToEvent` * Refactor `calcAppsStatus` * Assign `evt` to resutl of `addVideoCallDataToEvent` * Use prisma.transaction when moving attendees * Clean create seat call * Use ErrorCode enum * Use attendeeRescheduledSeatedBooking function * Await function * Prevent double triggering of workflows * Use inviteeToAdd in createNewSeat * Remove unused error code * Remove old handleSeats file * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix * Type fix --------- Co-authored-by: Morgan <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Erik <[email protected]>
This commit is contained in:
16 files changed
+2917
-1788
No files matched your search
@@ -129,6 +129,8 @@ export type InputEventType = {
|
||||
durationLimits?: IntervalLimit;
|
||||
} & Partial<Omit<Prisma.EventTypeCreateInput, "users" | "schedule" | "bookingLimits" | "durationLimits">>;
|
||||
|
||||
type AttendeeBookingSeatInput = Pick<Prisma.BookingSeatCreateInput, "referenceUid" | "data">;
|
||||
|
||||
type WhiteListedBookingProps = {
|
||||
id?: number;
|
||||
uid?: string;
|
||||
@@ -138,11 +140,15 @@ type WhiteListedBookingProps = {
|
||||
endTime: string;
|
||||
title?: string;
|
||||
status: BookingStatus;
|
||||
attendees?: { email: string }[];
|
||||
attendees?: {
|
||||
email: string;
|
||||
bookingSeat?: AttendeeBookingSeatInput | null;
|
||||
}[];
|
||||
references?: (Omit<ReturnType<typeof getMockBookingReference>, "credentialId"> & {
|
||||
// TODO: Make sure that all references start providing credentialId and then remove this intersection of optional credentialId
|
||||
credentialId?: number | null;
|
||||
})[];
|
||||
bookingSeat?: Prisma.BookingSeatCreateInput[];
|
||||
};
|
||||
|
||||
type InputBooking = Partial<Omit<Booking, keyof WhiteListedBookingProps>> & WhiteListedBookingProps;
|
||||
@@ -335,7 +341,7 @@ async function addBookings(bookings: InputBooking[]) {
|
||||
);
|
||||
}
|
||||
return {
|
||||
uid: uuidv4(),
|
||||
uid: booking.uid || uuidv4(),
|
||||
workflowReminders: [],
|
||||
references: [],
|
||||
title: "Test Booking Title",
|
||||
@@ -362,10 +368,23 @@ async function addBookings(bookings: InputBooking[]) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
createMany: {
|
||||
data: booking.attendees,
|
||||
data: booking.attendees.map((attendee) => {
|
||||
if (attendee.bookingSeat) {
|
||||
const { bookingSeat, ...attendeeWithoutBookingSeat } = attendee;
|
||||
return {
|
||||
...attendeeWithoutBookingSeat,
|
||||
bookingSeat: {
|
||||
create: { ...bookingSeat, bookingId: booking.id },
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return attendee;
|
||||
}
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return bookingCreate;
|
||||
})
|
||||
);
|
||||
@@ -1398,13 +1417,18 @@ export function getMockBookingReference(
|
||||
};
|
||||
}
|
||||
|
||||
export function getMockBookingAttendee(attendee: Omit<Attendee, "bookingId">) {
|
||||
export function getMockBookingAttendee(
|
||||
attendee: Omit<Attendee, "bookingId"> & {
|
||||
bookingSeat?: AttendeeBookingSeatInput;
|
||||
}
|
||||
) {
|
||||
return {
|
||||
id: attendee.id,
|
||||
timeZone: attendee.timeZone,
|
||||
name: attendee.name,
|
||||
email: attendee.email,
|
||||
locale: attendee.locale,
|
||||
bookingSeat: attendee.bookingSeat || null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user