ad7d49ef8f
* add expo-contacts * add expo-sms * update copy * add basic settings screen * state machine, flow screen * phone input screen * otp screen * tweak spacing * resend code logic * add layoutanimationconfig * check availablility in settings screen * get contacts * matches screen * search, temp setup for matches UI * add a bunch of number parsing logic with libphonenumber * cast to looser type * rename sync to find FCF (Find Contacts Flow) * update geolocation hook * nicer design for settings screen * add completed state * up border contrast * update expo deps * add pending spinner * add country whitelist * add empty state screen * drop add more functionality * upload -> import * fix typo * fix permission string * copy updates * rm envelope icon * update sms copy * add inviteinfo component * woke is back * [Contacts] NUXes (#9515) * add a bunch of number parsing logic with libphonenumber * add banner nux * add announcement nux * native only nux * rm shitty animation * move isNative check * [Contacts] Onboarding step (#9489) * add a bunch of number parsing logic with libphonenumber * restructure onboarding to better support dynamic screens * integrate existing flow into onboarding * add intro step * lift state up to allow going back freely * gate onboarding by geo if unsupported country * add done button to standalone flow * [Contacts] Add `contact-match` notification type to feed (#9519) * add a bunch of number parsing logic with libphonenumber * add contact-joined notif type * update string, api package * Update NotificationFeedItem.tsx * Update NotificationFeedItem.tsx * Delete SyncContactsFlow.web.tsx * fix follow back btn for this case * [Contacts] API integration (#9487) * api integration for flow * copy tweak * tweaks after running it * wire up status page * rename toast * use api lib * rm temp code * maybe fix otp error * clear code on error/resend * add 1s delay to verify success * update package versions * Delete SyncContactsFlow.web.tsx * try and fix yarn.lock lint * even woker * fix uppercase friends * surfdude feedback Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * rm log * allow resend on invalid code * Update GetContacts.tsx * overwrite country code if possible * fix Apple's Best Feature * devenv latest * disable bounces * interactive keyboard dismiss * copy changes * national format * allow resending immediately * move success state down a bit * Update FindContactsSettings.tsx * [Contacts] More onboarding changes (#9491) * integrate existing flow into onboarding * refreshed onboarding styles, rm stepper * center content on web * Add back dismiss button for internal onboarding * Import sort --------- Co-authored-by: Eric Bailey <git@esb.lol> * add matches query to shadow * add clockwise arrow * update status design, fix dismiss, fix queries * add metrics * add more comments * Update metrics.ts * refetch both queries on PTR * fix shadow state in matches page * reduce empty space at bottom * show contact info on matches * filter out contacts without numbers at an earlier stage * Error handling ✨ * get notifs working * filter out businesses * rm log * remove TODO from learn more links * try and exclude from web bundle --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> Co-authored-by: Eric Bailey <git@esb.lol>
134 lines
4.4 KiB
TypeScript
134 lines
4.4 KiB
TypeScript
import {useEffect, useState} from 'react'
|
|
import {View} from 'react-native'
|
|
import {msg, Trans} from '@lingui/macro'
|
|
import {useLingui} from '@lingui/react'
|
|
|
|
import {isNative} from '#/platform/detection'
|
|
import {useAgent, useSession} from '#/state/session'
|
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
|
import * as Dialog from '#/components/Dialog'
|
|
import {type DialogControlProps} from '#/components/Dialog'
|
|
import {useConfirmEmail} from '#/components/dialogs/EmailDialog/data/useConfirmEmail'
|
|
import {Divider} from '#/components/Divider'
|
|
import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as Resend} from '#/components/icons/ArrowRotate'
|
|
import {useIntentDialogs} from '#/components/intents/IntentDialogs'
|
|
import {Loader} from '#/components/Loader'
|
|
import {Text} from '#/components/Typography'
|
|
|
|
export function VerifyEmailIntentDialog() {
|
|
const {verifyEmailDialogControl: control} = useIntentDialogs()
|
|
|
|
return (
|
|
<Dialog.Outer control={control}>
|
|
<Dialog.Handle />
|
|
<Inner control={control} />
|
|
</Dialog.Outer>
|
|
)
|
|
}
|
|
|
|
function Inner({}: {control: DialogControlProps}) {
|
|
const t = useTheme()
|
|
const {gtMobile} = useBreakpoints()
|
|
const {_} = useLingui()
|
|
const {verifyEmailState: state} = useIntentDialogs()
|
|
const [status, setStatus] = useState<
|
|
'loading' | 'success' | 'failure' | 'resent'
|
|
>('loading')
|
|
const [sending, setSending] = useState(false)
|
|
const agent = useAgent()
|
|
const {currentAccount} = useSession()
|
|
const {mutate: confirmEmail} = useConfirmEmail({
|
|
onSuccess: () => setStatus('success'),
|
|
onError: () => setStatus('failure'),
|
|
})
|
|
|
|
useEffect(() => {
|
|
if (state?.code) {
|
|
confirmEmail({token: state.code})
|
|
}
|
|
}, [state?.code, confirmEmail])
|
|
|
|
const onPressResendEmail = async () => {
|
|
setSending(true)
|
|
await agent.com.atproto.server.requestEmailConfirmation()
|
|
setSending(false)
|
|
setStatus('resent')
|
|
}
|
|
|
|
return (
|
|
<Dialog.ScrollableInner
|
|
label={_(msg`Verify email dialog`)}
|
|
style={[
|
|
gtMobile ? {width: 'auto', maxWidth: 400, minWidth: 200} : a.w_full,
|
|
]}>
|
|
<View style={[a.gap_xl]}>
|
|
{status === 'loading' ? (
|
|
<View style={[a.py_2xl, a.align_center, a.justify_center]}>
|
|
<Loader size="xl" fill={t.atoms.text_contrast_low.color} />
|
|
</View>
|
|
) : status === 'success' ? (
|
|
<View style={[a.gap_sm, isNative && a.pb_xl]}>
|
|
<Text style={[a.font_bold, a.text_2xl]}>
|
|
<Trans>Email Verified</Trans>
|
|
</Text>
|
|
<Text style={[a.text_md, a.leading_snug]}>
|
|
<Trans>
|
|
Thanks, you have successfully verified your email address. You
|
|
can close this dialog.
|
|
</Trans>
|
|
</Text>
|
|
</View>
|
|
) : status === 'failure' ? (
|
|
<View style={[a.gap_sm]}>
|
|
<Text style={[a.font_bold, a.text_2xl]}>
|
|
<Trans>Invalid Verification Code</Trans>
|
|
</Text>
|
|
<Text style={[a.text_md, a.leading_snug]}>
|
|
<Trans>
|
|
The verification code you have provided is invalid. Please make
|
|
sure that you have used the correct verification link or request
|
|
a new one.
|
|
</Trans>
|
|
</Text>
|
|
</View>
|
|
) : (
|
|
<View style={[a.gap_sm, isNative && a.pb_xl]}>
|
|
<Text style={[a.font_bold, a.text_2xl]}>
|
|
<Trans>Email Resent</Trans>
|
|
</Text>
|
|
<Text style={[a.text_md, a.leading_snug]}>
|
|
<Trans>
|
|
We have sent another verification email to{' '}
|
|
<Text style={[a.text_md, a.font_semi_bold]}>
|
|
{currentAccount?.email}
|
|
</Text>
|
|
.
|
|
</Trans>
|
|
</Text>
|
|
</View>
|
|
)}
|
|
|
|
{status === 'failure' && (
|
|
<>
|
|
<Divider />
|
|
<Button
|
|
label={_(msg`Resend Verification Email`)}
|
|
onPress={onPressResendEmail}
|
|
color="secondary_inverted"
|
|
size="large"
|
|
disabled={sending}>
|
|
<ButtonIcon icon={sending ? Loader : Resend} />
|
|
<ButtonText>
|
|
<Trans>Resend Email</Trans>
|
|
</ButtonText>
|
|
</Button>
|
|
</>
|
|
)}
|
|
</View>
|
|
|
|
<Dialog.Close />
|
|
</Dialog.ScrollableInner>
|
|
)
|
|
}
|