From e1b000870c47869d2a3c3006e06a192706a64ddb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Apr 2026 19:52:06 +0000 Subject: [PATCH] Enforce 120-day maximum on FP workflow expiration date --- backend/routes/ivantiFpWorkflow.js | 6 ++++++ frontend/src/components/pages/ReportingPage.js | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/routes/ivantiFpWorkflow.js b/backend/routes/ivantiFpWorkflow.js index 7ccf025..a77c831 100644 --- a/backend/routes/ivantiFpWorkflow.js +++ b/backend/routes/ivantiFpWorkflow.js @@ -67,6 +67,12 @@ function validateFpWorkflowForm(body) { expDay.setHours(0, 0, 0, 0); if (expDay <= today) { errors.expirationDate = 'Expiration date must be in the future.'; + } else { + const maxDate = new Date(today); + maxDate.setDate(maxDate.getDate() + 120); + if (expDay > maxDate) { + errors.expirationDate = 'Expiration date cannot be more than 120 days from today.'; + } } } } diff --git a/frontend/src/components/pages/ReportingPage.js b/frontend/src/components/pages/ReportingPage.js index 433bcaf..7e2c273 100644 --- a/frontend/src/components/pages/ReportingPage.js +++ b/frontend/src/components/pages/ReportingPage.js @@ -2273,6 +2273,11 @@ function FpWorkflowModal({ open, onClose, selectedItems, onSuccess }) { today.setHours(0, 0, 0, 0); const exp = new Date(expirationDate + 'T00:00:00'); if (exp <= today) errs.expirationDate = 'Expiration date must be in the future'; + else { + const maxDate = new Date(today); + maxDate.setDate(maxDate.getDate() + 120); + if (exp > maxDate) errs.expirationDate = 'Expiration date cannot be more than 120 days from today'; + } } setErrors(errs); return Object.keys(errs).length === 0; @@ -2604,6 +2609,8 @@ function FpWorkflowModal({ open, onClose, selectedItems, onSuccess }) { type="date" value={expirationDate} onChange={e => setExpirationDate(e.target.value)} + min={(() => { const d = new Date(); d.setDate(d.getDate() + 1); return d.toISOString().split('T')[0]; })()} + max={(() => { const d = new Date(); d.setDate(d.getDate() + 120); return d.toISOString().split('T')[0]; })()} disabled={submitting} style={errors.expirationDate ? inputErrorStyle : inputStyle} /> @@ -2975,7 +2982,7 @@ function FpEditModal({ open, onClose, submission, queueItems, onSuccess }) {
- setExpirationDate(e.target.value)} disabled={isApproved} style={inputStyle} /> + setExpirationDate(e.target.value)} disabled={isApproved} min={(() => { const d = new Date(); d.setDate(d.getDate() + 1); return d.toISOString().split('T')[0]; })()} max={(() => { const d = new Date(); d.setDate(d.getDate() + 120); return d.toISOString().split('T')[0]; })()} style={inputStyle} />