From d25310948f7265ba4f7fed2eb54ac701f0198015 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 9 Jul 2025 20:32:32 -0500 Subject: [PATCH] Clean up intent dialog on native --- .../AgeAssuranceRedirectDialog.tsx | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/components/ageAssurance/AgeAssuranceRedirectDialog.tsx b/src/components/ageAssurance/AgeAssuranceRedirectDialog.tsx index 9ef1ef965c..4dadf9805a 100644 --- a/src/components/ageAssurance/AgeAssuranceRedirectDialog.tsx +++ b/src/components/ageAssurance/AgeAssuranceRedirectDialog.tsx @@ -5,15 +5,17 @@ import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' import {retry} from '#/lib/async/retry' +import {isNative} from '#/platform/detection' import {createAgeAssuranceQueryKey} from '#/state/age-assurance' import {useAgent} from '#/state/session' -import {atoms as a, web} from '#/alf' +import {atoms as a, useTheme, web} from '#/alf' import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge' +import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {useGlobalDialogsControlContext} from '#/components/dialogs/Context' +import {CircleInfo_Stroke2_Corner0_Rounded as ErrorIcon} from '#/components/icons/CircleInfo' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' -import {Admonition} from '../Admonition' export type AgeAssuranceRedirectDialogState = { status: 'success' | 'unknown' @@ -59,6 +61,8 @@ export function AgeAssuranceRedirectDialog() { const {_} = useLingui() const control = useAgeAssuranceRedirectDialogControl() + // Dialog.useAutoOpen(control.control, 1e3) + // TODO maybe handle invalid DID here return ( @@ -75,13 +79,14 @@ export function AgeAssuranceRedirectDialog() { } export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) { + const t = useTheme() const {_} = useLingui() const qc = useQueryClient() const agent = useAgent() const polling = useRef(false) const unmounted = useRef(false) const control = useAgeAssuranceRedirectDialogControl() - const [error, setError] = useState('') + const [error, setError] = useState(false) useEffect(() => { if (polling.current) return @@ -119,21 +124,17 @@ export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) { }) .catch(() => { if (unmounted.current) return - setError( - _( - msg`We were unable to verify your age assurance status. But don't worry! Your account should be updated soon.`, - ), - ) + setError(true) }) return () => { unmounted.current = true } - }, [_, agent, qc, control]) + }, [agent, qc, control]) return ( <> - + + {error && } + - Verifying + {error ? Unknown status : Verifying} {!error && } - - We're confirming your status with our servers. This dialog should - close in a few seconds. - + {error ? ( + + We were unable to verify your age assurance status. But don't + worry! Your account should be updated soon. + + ) : ( + + We're confirming your status with our servers. This dialog should + close in a few seconds. + + )} - {error && ( - - {error} + {error && isNative && ( + + )}