Skip to content

Commit

Permalink
Merge pull request #68 from openimis/feature/OP-1806
Browse files Browse the repository at this point in the history
OP-1806: fix calendar picker to allow selecting future dates
  • Loading branch information
delcroip authored Feb 9, 2024
2 parents 24c4cf1 + 03fdd7c commit 0e69145
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/ContractHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,13 @@ class ContractHeadPanel extends FormPanel {
module="contract"
label="dateValidFrom"
required
maxDate={!!edited && !!edited.dateValidTo && edited.dateValidTo}
value={!!edited && !!edited.dateValidFrom && edited.dateValidFrom}
onChange={(v) => this.updateAttribute("dateValidFrom", v)}
readOnly={readOnlyFields.includes("dateValidFrom") || isAmendment}
// NOTE: maxDate cannot be passed if dateValidTo does not exist.
// Passing any other falsy value will block months manipulation.
// eslint-disable-next-line react/jsx-props-no-spreading
{...(edited.dateValidTo ? { maxDate: edited.dateValidTo } : null)}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
Expand All @@ -292,12 +295,13 @@ class ContractHeadPanel extends FormPanel {
module="contract"
label="dateValidTo"
required
minDate={
!!edited && !!edited.dateValidFrom && edited.dateValidFrom
}
value={!!edited && !!edited.dateValidTo && edited.dateValidTo}
onChange={(v) => this.updateAttribute("dateValidTo", v)}
readOnly={readOnlyFields.includes("dateValidTo")}
// NOTE: minDate cannot be passed if dateValidFrom does not exist.
// Passing any other falsy value will block months manipulation.
// eslint-disable-next-line react/jsx-props-no-spreading
{...(edited.dateValidFrom ? { minDate: edited.dateValidFrom } : null)}
/>
</Grid>
</Grid>
Expand Down

0 comments on commit 0e69145

Please sign in to comment.