diff --git a/src/components/field/ReservedValues.js b/src/components/field/ReservedValues.js index 4de00fc8..9a5e6ade 100644 --- a/src/components/field/ReservedValues.js +++ b/src/components/field/ReservedValues.js @@ -25,6 +25,7 @@ export const ReservedValues = ({ onChange, value, ...props }) => { value={value[CODE]} warning={value[CODE] >= MAXVALUE} step="10" + min="0" inputWidth="120px" validationText={i18n.t( 'Recommended maximum is {{maxValue}} reserved values', diff --git a/src/pages/General/helper.js b/src/pages/General/helper.js index c432b919..e04c63ff 100644 --- a/src/pages/General/helper.js +++ b/src/pages/General/helper.js @@ -1,3 +1,4 @@ +import isNil from 'lodash/isNil' import { defaultEncryptDB, defaultReservedValues, @@ -41,8 +42,15 @@ export const createInitialValues = (prevGeneralDetails) => ({ matomoID: prevGeneralDetails.matomoID || '', smsGateway: prevGeneralDetails.smsGateway || '', smsResultSender: prevGeneralDetails.smsResultSender || '', - reservedValues: prevGeneralDetails.reservedValues || defaultReservedValues, + reservedValues: validReservedValue(prevGeneralDetails.reservedValues), encryptDB: prevGeneralDetails.encryptDB || defaultEncryptDB, allowScreenCapture: prevGeneralDetails.allowScreenCapture || defaultShareScreen, }) + +const validReservedValue = (value) => { + if (isNil(value) || !isValidValue(value)) { + return defaultReservedValues + } + return value +}