191 lines
7.5 KiB
Diff
191 lines
7.5 KiB
Diff
--- a/src/screens/Signup/StepInfo/index.tsx
|
|
+++ b/src/screens/Signup/StepInfo/index.tsx
|
|
@@ -9,44 +9,17 @@
|
|
import {logger} from '#/logger'
|
|
import {isNative} from '#/platform/detection'
|
|
import {useSignupContext} from '#/screens/Signup/state'
|
|
-import {Policies} from '#/screens/Signup/StepInfo/Policies'
|
|
import {atoms as a, native} from '#/alf'
|
|
-import * as Admonition from '#/components/Admonition'
|
|
-import * as Dialog from '#/components/Dialog'
|
|
-import {DeviceLocationRequestDialog} from '#/components/dialogs/DeviceLocationRequestDialog'
|
|
-import * as DateField from '#/components/forms/DateField'
|
|
-import {type DateFieldRef} from '#/components/forms/DateField/types'
|
|
import {FormError} from '#/components/forms/FormError'
|
|
import {HostingProvider} from '#/components/forms/HostingProvider'
|
|
import * as TextField from '#/components/forms/TextField'
|
|
import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/Envelope'
|
|
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
|
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
|
-import {createStaticClick, SimpleInlineLinkText} from '#/components/Link'
|
|
import {Loader} from '#/components/Loader'
|
|
import {usePreemptivelyCompleteActivePolicyUpdate} from '#/components/PolicyUpdateOverlay/usePreemptivelyCompleteActivePolicyUpdate'
|
|
-import * as Toast from '#/components/Toast'
|
|
-import {
|
|
- isUnderAge,
|
|
- MIN_ACCESS_AGE,
|
|
- useAgeAssuranceRegionConfigWithFallback,
|
|
-} from '#/ageAssurance/util'
|
|
-import {
|
|
- useDeviceGeolocationApi,
|
|
- useIsDeviceGeolocationGranted,
|
|
-} from '#/geolocation'
|
|
import {BackNextButtons} from '../BackNextButtons'
|
|
|
|
-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
|
|
-}
|
|
-
|
|
export function StepInfo({
|
|
onPressBack,
|
|
isServerError,
|
|
@@ -70,21 +43,6 @@
|
|
|
|
const emailInputRef = useRef<TextInput>(null)
|
|
const passwordInputRef = useRef<TextInput>(null)
|
|
- const birthdateInputRef = useRef<DateFieldRef>(null)
|
|
-
|
|
- const aaRegionConfig = useAgeAssuranceRegionConfigWithFallback()
|
|
- const {setDeviceGeolocation} = useDeviceGeolocationApi()
|
|
- const locationControl = Dialog.useDialogControl()
|
|
- const isOverRegionMinAccessAge = state.dateOfBirth
|
|
- ? !isUnderAge(state.dateOfBirth.toISOString(), aaRegionConfig.minAccessAge)
|
|
- : true
|
|
- const isOverAppMinAccessAge = state.dateOfBirth
|
|
- ? !isUnderAge(state.dateOfBirth.toISOString(), MIN_ACCESS_AGE)
|
|
- : true
|
|
- const isOverMinAdultAge = state.dateOfBirth
|
|
- ? !isUnderAge(state.dateOfBirth.toISOString(), 18)
|
|
- : true
|
|
- const isDeviceGeolocationGranted = useIsDeviceGeolocationGranted()
|
|
|
|
const [hasWarnedEmail, setHasWarnedEmail] = React.useState<boolean>(false)
|
|
|
|
@@ -105,10 +63,6 @@
|
|
const emailChanged = prevEmailValueRef.current !== email
|
|
const password = passwordValueRef.current
|
|
|
|
- if (!isOverRegionMinAccessAge) {
|
|
- return
|
|
- }
|
|
-
|
|
if (state.serviceDescription?.inviteCodeRequired && !inviteCode) {
|
|
return dispatch({
|
|
type: 'setError',
|
|
@@ -275,107 +229,16 @@
|
|
secureTextEntry
|
|
autoComplete="new-password"
|
|
autoCapitalize="none"
|
|
- returnKeyType="next"
|
|
- submitBehavior={native('blurAndSubmit')}
|
|
- onSubmitEditing={native(() =>
|
|
- birthdateInputRef.current?.focus(),
|
|
- )}
|
|
+ returnKeyType="done"
|
|
passwordRules="minlength: 8;"
|
|
/>
|
|
</TextField.Root>
|
|
</View>
|
|
- <View>
|
|
- <DateField.LabelText>
|
|
- <Trans>Your birth date</Trans>
|
|
- </DateField.LabelText>
|
|
- <DateField.DateField
|
|
- testID="date"
|
|
- inputRef={birthdateInputRef}
|
|
- value={state.dateOfBirth}
|
|
- onChangeDate={date => {
|
|
- dispatch({
|
|
- type: 'setDateOfBirth',
|
|
- value: sanitizeDate(new Date(date)),
|
|
- })
|
|
- }}
|
|
- label={_(msg`Date of birth`)}
|
|
- accessibilityHint={_(msg`Select your date of birth`)}
|
|
- maximumDate={new Date()}
|
|
- />
|
|
- </View>
|
|
-
|
|
- <View style={[a.gap_sm]}>
|
|
- <Policies serviceDescription={state.serviceDescription} />
|
|
-
|
|
- {!isOverRegionMinAccessAge || !isOverAppMinAccessAge ? (
|
|
- <Admonition.Outer type="error">
|
|
- <Admonition.Row>
|
|
- <Admonition.Icon />
|
|
- <Admonition.Content>
|
|
- <Admonition.Text>
|
|
- {!isOverAppMinAccessAge ? (
|
|
- <Trans>
|
|
- You must be {MIN_ACCESS_AGE} years of age or older
|
|
- to create an account.
|
|
- </Trans>
|
|
- ) : (
|
|
- <Trans>
|
|
- You must be {aaRegionConfig.minAccessAge} years of
|
|
- age or older to create an account in your region.
|
|
- </Trans>
|
|
- )}
|
|
- </Admonition.Text>
|
|
- {isNative &&
|
|
- !isDeviceGeolocationGranted &&
|
|
- isOverAppMinAccessAge && (
|
|
- <Admonition.Text>
|
|
- <Trans>
|
|
- Have we got your location wrong?{' '}
|
|
- <SimpleInlineLinkText
|
|
- label={_(
|
|
- msg`Tap here to confirm your location with GPS.`,
|
|
- )}
|
|
- {...createStaticClick(() => {
|
|
- locationControl.open()
|
|
- })}>
|
|
- Tap here to confirm your location with GPS.
|
|
- </SimpleInlineLinkText>
|
|
- </Trans>
|
|
- </Admonition.Text>
|
|
- )}
|
|
- </Admonition.Content>
|
|
- </Admonition.Row>
|
|
- </Admonition.Outer>
|
|
- ) : !isOverMinAdultAge ? (
|
|
- <Admonition.Admonition type="warning">
|
|
- <Trans>
|
|
- If you are not yet an adult according to the laws of your
|
|
- country, your parent or legal guardian must read these Terms
|
|
- on your behalf.
|
|
- </Trans>
|
|
- </Admonition.Admonition>
|
|
- ) : undefined}
|
|
- </View>
|
|
-
|
|
- {isNative && (
|
|
- <DeviceLocationRequestDialog
|
|
- control={locationControl}
|
|
- onLocationAcquired={props => {
|
|
- props.closeDialog(() => {
|
|
- // set this after close!
|
|
- setDeviceGeolocation(props.geolocation)
|
|
- Toast.show(_(msg`Your location has been updated.`), {
|
|
- type: 'success',
|
|
- })
|
|
- })
|
|
- }}
|
|
- />
|
|
- )}
|
|
</>
|
|
) : undefined}
|
|
</View>
|
|
<BackNextButtons
|
|
- hideNext={!isOverRegionMinAccessAge}
|
|
+ hideNext={false}
|
|
showRetry={isServerError}
|
|
isLoading={state.isLoading}
|
|
onBackPress={onPressBack}
|