fix: Do not fallback to existing db value if input is null for settings. (#21413)
* fix: Do not fallback to existing db value if input is null for settings. Fixes #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. * update * update --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: unknown <adhabal2002@gmail.com> Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com> Co-authored-by: Devanshu Sharma <devanshusharma658@gmail.com>
This commit is contained in:
co-authored by
Anik Dhabal Babu
unknown
Kartik Saini
Devanshu Sharma
parent
ada8ffd3b9
commit
84a742336c
@@ -332,8 +332,9 @@ export const useEventTypeForm = ({
|
||||
} = dirtyValues;
|
||||
if (length && !Number(length)) throw new Error(t("event_setup_length_error"));
|
||||
|
||||
const finalSeatsPerTimeSlot = seatsPerTimeSlot ?? values.seatsPerTimeSlot;
|
||||
const finalRecurringEvent = recurringEvent ?? values.recurringEvent;
|
||||
const finalSeatsPerTimeSlot =
|
||||
seatsPerTimeSlot === undefined ? eventType.seatsPerTimeSlot : seatsPerTimeSlot;
|
||||
const finalRecurringEvent = recurringEvent === undefined ? eventType.recurringEvent : recurringEvent;
|
||||
|
||||
if (finalSeatsPerTimeSlot && finalRecurringEvent) {
|
||||
throw new Error(t("recurring_event_seats_error"));
|
||||
|
||||
@@ -195,8 +195,9 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
|
||||
const finalSeatsPerTimeSlot = seatsPerTimeSlot ?? eventType.seatsPerTimeSlot;
|
||||
const finalRecurringEvent = recurringEvent ?? eventType.recurringEvent;
|
||||
const finalSeatsPerTimeSlot =
|
||||
seatsPerTimeSlot === undefined ? eventType.seatsPerTimeSlot : seatsPerTimeSlot;
|
||||
const finalRecurringEvent = recurringEvent === undefined ? eventType.recurringEvent : recurringEvent;
|
||||
|
||||
if (finalSeatsPerTimeSlot && finalRecurringEvent) {
|
||||
throw new TRPCError({
|
||||
|
||||
Reference in New Issue
Block a user