-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 ui(birthdates): Improve birth date pickers.
This is the last step of #60.
- Loading branch information
1 parent
d64cb74
commit f85fe0a
Showing
3 changed files
with
148 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {useMemo} from 'react'; | ||
|
||
import format from 'date-fns/format'; | ||
import endOfToday from 'date-fns/endOfToday'; | ||
import parseISO from 'date-fns/parseISO'; | ||
import subYears from 'date-fns/subYears'; | ||
|
||
import {useDateMask} from '../../i18n/datetime'; | ||
|
||
const useBirthdatePickerProps = () => { | ||
const mask = useDateMask(); | ||
const maxDateString = format(endOfToday(), 'yyyy-MM-dd'); | ||
|
||
return useMemo(() => { | ||
const maxDate = parseISO(maxDateString); | ||
const minDate = subYears(maxDate, 200); | ||
return {minDate, maxDate, mask}; | ||
}, [maxDateString, mask]); | ||
}; | ||
|
||
export default useBirthdatePickerProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters