Skip to content

Commit c2ea37f

Browse files
committed
fix: Do not fallback to existing db value if input is null for settings.
Fixes calcom#21412. For `finalSeatsPerTimeSlot` and `finalRecurringEvent` we were falling back to the DB value if `seatsPerTimeSlot` or `recurringEvent` was falsy. Instead, we should only fallback to the DB value if those values are undefined. Those values being undefined means that they have not changed, while those values being null means they are being reset to not have any value in them. This was causing an error when a user was trying to turn off `Recurring event` and turn on `Offer seats` in the same event.
1 parent 25246ef commit c2ea37f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/trpc/server/routers/viewer/eventTypes/update.handler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
163163
throw new TRPCError({ code: "UNAUTHORIZED" });
164164
}
165165

166-
const finalSeatsPerTimeSlot = seatsPerTimeSlot ?? eventType.seatsPerTimeSlot;
167-
const finalRecurringEvent = recurringEvent ?? eventType.recurringEvent;
166+
const finalSeatsPerTimeSlot =
167+
seatsPerTimeSlot === undefined ? eventType.seatsPerTimeSlot : seatsPerTimeSlot;
168+
const finalRecurringEvent = recurringEvent === undefined ? eventType.recurringEvent : recurringEvent;
168169

169170
if (finalSeatsPerTimeSlot && finalRecurringEvent) {
170171
throw new TRPCError({

0 commit comments

Comments
 (0)