diff options
author | Hailey <me@haileyok.com> | 2024-11-12 11:18:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 11:18:53 -0800 |
commit | 427f3a8bd7f21f14aef32af2f7ccf1f4b2731c29 (patch) | |
tree | 4b365327a7438a5d24f880c6cc38bf1a9033fe0c /src/components/dialogs | |
parent | dd8d14e133f5f705a4056d95a76542aeea26db28 (diff) | |
download | voidsky-427f3a8bd7f21f14aef32af2f7ccf1f4b2731c29.tar.zst |
Add email verification prompts throughout the app (#6174)
Diffstat (limited to 'src/components/dialogs')
-rw-r--r-- | src/components/dialogs/VerifyEmailDialog.tsx | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/src/components/dialogs/VerifyEmailDialog.tsx b/src/components/dialogs/VerifyEmailDialog.tsx index 8dfb9bc49..d4412b6f8 100644 --- a/src/components/dialogs/VerifyEmailDialog.tsx +++ b/src/components/dialogs/VerifyEmailDialog.tsx @@ -18,8 +18,14 @@ import {Text} from '#/components/Typography' export function VerifyEmailDialog({ control, + onCloseWithoutVerifying, + onCloseAfterVerifying, + reasonText, }: { control: Dialog.DialogControlProps + onCloseWithoutVerifying?: () => void + onCloseAfterVerifying?: () => void + reasonText?: string }) { const agent = useAgent() @@ -30,18 +36,24 @@ export function VerifyEmailDialog({ control={control} onClose={async () => { if (!didVerify) { + onCloseWithoutVerifying?.() return } try { await agent.resumeSession(agent.session!) + onCloseAfterVerifying?.() } catch (e: unknown) { logger.error(String(e)) return } }}> <Dialog.Handle /> - <Inner control={control} setDidVerify={setDidVerify} /> + <Inner + control={control} + setDidVerify={setDidVerify} + reasonText={reasonText} + /> </Dialog.Outer> ) } @@ -49,9 +61,11 @@ export function VerifyEmailDialog({ export function Inner({ control, setDidVerify, + reasonText, }: { control: Dialog.DialogControlProps setDidVerify: (value: boolean) => void + reasonText?: string }) { const {_} = useLingui() const {currentAccount} = useSession() @@ -135,26 +149,32 @@ export function Inner({ <Text style={[a.text_md, a.leading_snug]}> {currentStep === 'StepOne' ? ( <> - <Trans> - You'll receive an email at{' '} - <Text style={[a.text_md, a.leading_snug, a.font_bold]}> - {currentAccount?.email} - </Text>{' '} - to verify it's you. - </Trans>{' '} - <InlineLinkText - to="#" - label={_(msg`Change email address`)} - style={[a.text_md, a.leading_snug]} - onPress={e => { - e.preventDefault() - control.close(() => { - openModal({name: 'change-email'}) - }) - return false - }}> - <Trans>Need to change it?</Trans> - </InlineLinkText> + {!reasonText ? ( + <> + <Trans> + You'll receive an email at{' '} + <Text style={[a.text_md, a.leading_snug, a.font_bold]}> + {currentAccount?.email} + </Text>{' '} + to verify it's you. + </Trans>{' '} + <InlineLinkText + to="#" + label={_(msg`Change email address`)} + style={[a.text_md, a.leading_snug]} + onPress={e => { + e.preventDefault() + control.close(() => { + openModal({name: 'change-email'}) + }) + return false + }}> + <Trans>Need to change it?</Trans> + </InlineLinkText> + </> + ) : ( + reasonText + )} </> ) : ( uiStrings[currentStep].message |