Enforce 120-day maximum on FP workflow expiration date
This commit is contained in:
@@ -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.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }) {
|
||||
<div style={{ display: 'flex', gap: '0.75rem' }}>
|
||||
<div style={{ flex: 1 }}>
|
||||
<label style={labelStyle}>Expiration Date</label>
|
||||
<input type="date" value={expirationDate} onChange={(e) => setExpirationDate(e.target.value)} disabled={isApproved} style={inputStyle} />
|
||||
<input type="date" value={expirationDate} onChange={(e) => 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} />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<label style={labelStyle}>Scope Override</label>
|
||||
|
||||
Reference in New Issue
Block a user