feat: Restrict same email to create more than 'n' active bookings at… (#21745)
* feat - Restrict same email to create more than 'n' active bookings at a time * updated checkbookerbookinglimit function * type fix * minor change * import fix * minor fixes * back to null on disable * back * type check * managed edge cases * chore: name changes * name changes * fix * minor change * changed name * use default value for maxactivebookingsperbooker, and some minor changes * disabling bookerbooking limit for recurring event * disabling bookerbooking limit for recurring event * type fix * ui fix and backend eventtype update check * removed unused code * minor changes * update validation * chore * Do not check booking limits if rescheduling * minor fix * Refactor eventType update errors * Typo fix --------- Co-authored-by: Joe Au-Yeung <[email protected]>
This commit is contained in:
1 parent
ddf5717992
commit
630065ca89
16 files changed
+143
-2
No files matched your search
@@ -64,6 +64,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
locations,
|
||||
bookingLimits,
|
||||
durationLimits,
|
||||
maxActiveBookingsPerBooker,
|
||||
destinationCalendar,
|
||||
customInputs,
|
||||
recurringEvent,
|
||||
@@ -98,6 +99,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
description: true,
|
||||
seatsPerTimeSlot: true,
|
||||
recurringEvent: true,
|
||||
maxActiveBookingsPerBooker: true,
|
||||
fieldTranslations: {
|
||||
select: {
|
||||
field: true,
|
||||
@@ -259,6 +261,24 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
data.bookingLimits = bookingLimits;
|
||||
}
|
||||
|
||||
if (maxActiveBookingsPerBooker && maxActiveBookingsPerBooker < 1) {
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "Booker booking limit must be greater than 0." });
|
||||
}
|
||||
|
||||
if (maxActiveBookingsPerBooker && (recurringEvent || eventType.recurringEvent)) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Recurring Events and booker active bookings limit cannot be active at the same time.",
|
||||
});
|
||||
}
|
||||
|
||||
if (eventType.maxActiveBookingsPerBooker && recurringEvent) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Recurring Events and booker active bookings limit cannot be active at the same time.",
|
||||
});
|
||||
}
|
||||
|
||||
if (durationLimits) {
|
||||
const isValid = validateIntervalLimitOrder(durationLimits);
|
||||
if (!isValid)
|
||||
|
||||
Reference in new issue
Block a user