Skip to content

Commit

Permalink
(fix) Recurring validation (#229)
Browse files Browse the repository at this point in the history
* If start date is not exist - hide last date input, disable endless checkbox

* Recurring: show error if last order date is not exist for non-endless node
  • Loading branch information
dmytroshch authored Sep 6, 2023
1 parent ec1549c commit efc901a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/recurring/meta/get_ui_def.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ const getUIDef = ({ i18n, isEditMode } = {}) => ({
minDate: null,
disabled: {
endless: { eq: true }
},
visible: {
startedAt: { exist: true }
}
},

Expand All @@ -131,7 +134,10 @@ const getUIDef = ({ i18n, isEditMode } = {}) => ({
].join(' ')
),
default: true,
customClassName: 'vertical-align'
customClassName: 'vertical-align',
disabled: {
startedAt: { exist: false }
}
},

action: {
Expand Down
6 changes: 5 additions & 1 deletion lib/recurring/meta/validate_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ const { apply: applyI18N } = require('../../util/i18n')
* description of which parameter is invalid.
*/
const validateParams = (args) => {
const { amount } = args
const { amount, endless, endedAt } = args
if (!_isFinite(amount) || amount === 0) {
return applyI18N(
validationErrObj('amount', 'Invalid amount'),
'invalidAmount'
)
}

if (!endless && !endedAt) {
return applyI18N(validationErrObj('endedAt', 'Last Order Date must be specified'), 'lastOrderDateRequired')
}

return null
}

Expand Down

0 comments on commit efc901a

Please sign in to comment.