diff --git a/apps/meteor/client/views/admin/settings/MemoizedSetting.tsx b/apps/meteor/client/views/admin/settings/MemoizedSetting.tsx index ef4e19a27a60..5d08909d6950 100644 --- a/apps/meteor/client/views/admin/settings/MemoizedSetting.tsx +++ b/apps/meteor/client/views/admin/settings/MemoizedSetting.tsx @@ -48,6 +48,7 @@ const inputsByType: Record> = { type MemoizedSettingProps = { _id?: string; type: ISettingBase['type']; + packageValue: ISettingBase['packageValue']; hint?: ReactNode; callout?: ReactNode; value?: SettingValue; diff --git a/apps/meteor/client/views/admin/settings/inputs/TimespanSettingInput.tsx b/apps/meteor/client/views/admin/settings/inputs/TimespanSettingInput.tsx index f90857721547..0609b45476cf 100644 --- a/apps/meteor/client/views/admin/settings/inputs/TimespanSettingInput.tsx +++ b/apps/meteor/client/views/admin/settings/inputs/TimespanSettingInput.tsx @@ -81,6 +81,7 @@ function TimespanSettingInput({ onChangeValue, hasResetButton, onResetButtonClick, + packageValue, }: TimespanSettingInputProps): ReactElement { const t = useTranslation(); @@ -90,7 +91,7 @@ function TimespanSettingInput({ const handleChange: FormEventHandler = (event) => { const newValue = sanitizeInputValue(Number(event.currentTarget.value)); - onChangeValue?.(newValue); + onChangeValue?.(timeUnitToMs(timeUnit, newValue)); setInternalValue(newValue); }; @@ -117,13 +118,20 @@ function TimespanSettingInput({ return Object.entries(TIMEUNIT).map(([label, value]) => [value, t.has(label) ? t(label) : label]); // todo translate }, [t]); + const handleResetButtonClick = () => { + onResetButtonClick?.(); + const newTimeUnit = getHighestTimeUnit(Number(packageValue)); + setTimeUnit(newTimeUnit); + setInternalValue(msToTimeUnit(newTimeUnit, Number(packageValue))); + }; + return ( {label} - {hasResetButton && } + {hasResetButton && } = { _id: string; label: ReactNode; value?: V; + packageValue: V; placeholder?: string; readonly?: boolean; autocomplete?: boolean;