Handle birth dates as UTC, handle locale formatting (#2363)
* Enforce UTC for birthdate picker * Handle locales * Remove log * Add a second snap point to the date input in case text is zoomed * Guard against bad dates * Log message --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
parent
23c9c8977b
commit
705f9b61ef
3 changed files with 31 additions and 3 deletions
|
@ -13,6 +13,17 @@ import {isWeb} from 'platform/detection'
|
|||
import {Trans, msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useModalControls} from '#/state/modals'
|
||||
import {logger} from '#/logger'
|
||||
|
||||
function sanitizeDate(date: Date): Date {
|
||||
if (!date || date.toString() === 'Invalid Date') {
|
||||
logger.error(`Create account: handled invalid date for birthDate`, {
|
||||
hasDate: !!date,
|
||||
})
|
||||
return new Date()
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
/** STEP 2: Your account
|
||||
* @field Invite code or waitlist
|
||||
|
@ -38,6 +49,10 @@ export function Step2({
|
|||
openModal({name: 'waitlist'})
|
||||
}, [openModal])
|
||||
|
||||
const birthDate = React.useMemo(() => {
|
||||
return sanitizeDate(uiState.birthDate)
|
||||
}, [uiState.birthDate])
|
||||
|
||||
return (
|
||||
<View>
|
||||
<StepHeader step="2" title={_(msg`Your account`)} />
|
||||
|
@ -122,8 +137,9 @@ export function Step2({
|
|||
<Trans>Your birth date</Trans>
|
||||
</Text>
|
||||
<DateInput
|
||||
handleAsUTC
|
||||
testID="birthdayInput"
|
||||
value={uiState.birthDate}
|
||||
value={birthDate}
|
||||
onChange={value => uiDispatch({type: 'set-birth-date', value})}
|
||||
buttonType="default-light"
|
||||
buttonStyle={[pal.border, styles.dateInputButton]}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue