Skip to content

Commit

Permalink
fix: allow set 0 reserved values
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharmyn28 committed Aug 7, 2023
1 parent 5dcbd50 commit 4fdb33d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/field/ReservedValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 9 additions & 1 deletion src/pages/General/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isNil from 'lodash/isNil'
import {
defaultEncryptDB,
defaultReservedValues,
Expand Down Expand Up @@ -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
}

0 comments on commit 4fdb33d

Please sign in to comment.