Skip to content

Commit

Permalink
Merge pull request #2511 from cozy/fix/allow-dates-without-months-as-…
Browse files Browse the repository at this point in the history
…values-in-selectdate

Make `SelectDates` accept values without months
  • Loading branch information
PolariTOON authored Sep 28, 2022
2 parents 5772bfe + 29ad6bd commit 9ac5f2a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectDates/SelectDates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import Select from 'components/Select'
import { rangedSome } from 'components/SelectDates/utils'
import { themed } from 'components/useTheme'

const isAllYear = value => value && value.includes('allyear')

const getOptionValue = option => option.value
const capitalizeFirstLetter = string => {
return string.charAt(0).toUpperCase() + string.slice(1)
Expand Down Expand Up @@ -115,6 +113,8 @@ class SelectDateButton extends PureComponent {
}

const isFullYearValue = value => value && value.length === 4
const isAllYear = value =>
value && (isFullYearValue(value) || value.includes('allyear'))
const isOptionEnabled = option => option && !option.isDisabled
const allDisabledFrom = (options, maxIndex) => {
return !rangedSome(options, isOptionEnabled, maxIndex, -1)
Expand Down Expand Up @@ -215,7 +215,7 @@ class SelectDates extends PureComponent {
value = nearest.value
}
}
if (value && value.includes('allyear')) {
if (allyear) {
value = value.substr(0, 4)
}

Expand Down

0 comments on commit 9ac5f2a

Please sign in to comment.