From a15b8fb92e49aeed18931351c779cfb0cffabc05 Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Tue, 31 Jan 2023 00:08:22 +0530 Subject: [PATCH] fix: booking limits saved as undefined (#6720) * fix: booking limits saved as undefined Signed-off-by: Udit Takkar * fix: add event limit Signed-off-by: Udit Takkar --------- Signed-off-by: Udit Takkar --- apps/web/components/eventtype/EventLimitsTab.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/components/eventtype/EventLimitsTab.tsx b/apps/web/components/eventtype/EventLimitsTab.tsx index 1d0f97765c..a5e7a30d2a 100644 --- a/apps/web/components/eventtype/EventLimitsTab.tsx +++ b/apps/web/components/eventtype/EventLimitsTab.tsx @@ -420,12 +420,14 @@ const BookingLimits = () => { defaultValue={BOOKING_LIMIT_OPTIONS.find((option) => option.value === key)} onChange={(val) => { const current = currentBookingLimits; + const currentValue = watchBookingLimits[bookingLimitKey]; + // Removes limit from previous selected value (eg when changed from per_week to per_month, we unset per_week here) delete current[bookingLimitKey]; const newData = { ...current, // Set limit to new selected value (in the example above this means we set the limit to per_week here). - [val?.value as BookingLimitsKey]: watchBookingLimits[bookingLimitKey], + [val?.value as BookingLimitsKey]: currentValue, }; onChange(newData); }} @@ -459,7 +461,7 @@ const BookingLimits = () => { setValue("bookingLimits", { ...watchBookingLimits, - [rest[0].value]: undefined, + [rest[0].value]: 1, }); }}> {t("add_limit")}