From 23596f5afe0bc69696136c3cabaab3071bd383b7 Mon Sep 17 00:00:00 2001 From: zaliqarosli Date: Tue, 20 Dec 2022 16:02:46 -0500 Subject: [PATCH] add date restriction --- modules/candidate_parameters/jsx/ConsentStatus.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/candidate_parameters/jsx/ConsentStatus.js b/modules/candidate_parameters/jsx/ConsentStatus.js index a2483973c7d..5ff7d012a2b 100644 --- a/modules/candidate_parameters/jsx/ConsentStatus.js +++ b/modules/candidate_parameters/jsx/ConsentStatus.js @@ -158,22 +158,29 @@ class ConsentStatus extends Component { let consentWithdrawal = consentStatus + '_withdrawal'; let consentWithdrawal2 = consentStatus + '_withdrawal2'; - date1 = myFormData[consentWithdrawal] ? + const withdrawDate1 = myFormData[consentWithdrawal] ? myFormData[consentWithdrawal] : null; - date2 = myFormData[consentWithdrawal2] ? + const withdrawDate2 = myFormData[consentWithdrawal2] ? myFormData[consentWithdrawal2] : null; - if (date1 !== date2) { + if (withdrawDate1 !== withdrawDate2) { alert(label + ' withdrawal dates do not match!'); return; } - if (date1 > today) { + if (withdrawDate1 > today) { alert( label + ' withdrawal date cannot be later than today!' ); return; } + if (withdrawDate1 < date1) { + alert( + label + + ' withdrawal date cannot be earlier than response date!' + ); + return; + } } } // Set form data