Fixed wrong calculation of duration type on event type page. (#5557)

pull/5554/head^2
Jeroen Reumkens 2022-11-17 09:08:03 +01:00 committed by GitHub
parent 5e2db12396
commit a8186e3039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -173,7 +173,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupInfered, "event
</div> </div>
</div> </div>
<div className="flex flex-col space-y-4 pt-4 lg:flex-row lg:space-y-0 lg:space-x-4"> <div className="flex flex-col space-y-4 pt-4 lg:flex-row lg:space-y-0 lg:space-x-4">
<div className="flex w-full items-end"> <div className="flex w-full items-end justify-end">
<Controller <Controller
name="minimumBookingNotice" name="minimumBookingNotice"
control={formMethods.control} control={formMethods.control}
@ -201,7 +201,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupInfered, "event
label={t("minimum_booking_notice")} label={t("minimum_booking_notice")}
type="number" type="number"
placeholder="120" placeholder="120"
className="mr-2 rounded-[4px]" className="mr-2 mb-0 h-[38px] rounded-[4px]"
{...formMethods.register("minimumBookingNoticeInDurationType", { {...formMethods.register("minimumBookingNoticeInDurationType", {
onChange: (event: React.ChangeEvent<HTMLInputElement>) => onChange: (event: React.ChangeEvent<HTMLInputElement>) =>
onMinimumNoticeChange(event.target.value), onMinimumNoticeChange(event.target.value),
@ -211,7 +211,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupInfered, "event
</div> </div>
<Select <Select
isSearchable={false} isSearchable={false}
className="mb-2 ml-2 w-full capitalize md:min-w-[150px] md:max-w-[200px]" className="mb-0 ml-2 h-[38px] w-full capitalize md:min-w-[150px] md:max-w-[200px]"
defaultValue={durationTypeOptions.find( defaultValue={durationTypeOptions.find(
(option) => option.value === minimumBookingNoticeType.current (option) => option.value === minimumBookingNoticeType.current
)} )}

View File

@ -12,13 +12,13 @@ export default function convertToNewDurationType(
/** Convert `prevValue` from `prevType` to `newType` */ /** Convert `prevValue` from `prevType` to `newType` */
const newDurationTypeMap = { const newDurationTypeMap = {
minutes_minutes: () => prevValue, minutes_minutes: () => prevValue,
minutes_hours: () => prevValue * MINUTES_IN_HOUR, minutes_hours: () => prevValue / MINUTES_IN_HOUR,
minutes_days: () => prevValue * MINUTES_IN_DAY, minutes_days: () => prevValue / MINUTES_IN_DAY,
hours_minutes: () => prevValue / MINUTES_IN_HOUR, hours_minutes: () => prevValue * MINUTES_IN_HOUR,
hours_hours: () => prevValue, hours_hours: () => prevValue,
hours_days: () => prevValue * HOURS_IN_DAY, hours_days: () => prevValue * HOURS_IN_DAY,
days_minutes: () => prevValue / MINUTES_IN_DAY, days_minutes: () => prevValue * MINUTES_IN_DAY,
days_hours: () => prevValue / HOURS_IN_DAY, days_hours: () => prevValue * HOURS_IN_DAY,
days_days: () => prevValue, days_days: () => prevValue,
}; };
const getNewValue = newDurationTypeMap[`${prevType}_${newType}`]; const getNewValue = newDurationTypeMap[`${prevType}_${newType}`];