From 58b20276ff4a075ca27021711d213eb8b20df796 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 8 Jan 2026 13:11:57 -0600 Subject: [PATCH] Add retry button and relayout to accommodate --- src/ageAssurance/data.tsx | 9 +++ .../ageAssurance/AgeAssuranceAdmonition.tsx | 2 +- .../AgeAssuranceDismissibleNotice.tsx | 57 ++++++++++--------- .../ageAssurance/AgeAssuranceErrors.tsx | 39 ++++++++++--- 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/src/ageAssurance/data.tsx b/src/ageAssurance/data.tsx index 4bbafa8214..f6353a899b 100644 --- a/src/ageAssurance/data.tsx +++ b/src/ageAssurance/data.tsx @@ -136,6 +136,15 @@ export async function prefetchConfig() { } }) } +export async function refetchConfig() { + logger.debug(`refetchConfig: fetching...`) + const res = await getConfig() + qc.setQueryData( + configQueryKey, + res, + ) + return res +} export function useConfigQuery() { return useQuery( { diff --git a/src/components/ageAssurance/AgeAssuranceAdmonition.tsx b/src/components/ageAssurance/AgeAssuranceAdmonition.tsx index 570ed3b4fb..1ef29dfbbb 100644 --- a/src/components/ageAssurance/AgeAssuranceAdmonition.tsx +++ b/src/components/ageAssurance/AgeAssuranceAdmonition.tsx @@ -21,7 +21,7 @@ export function AgeAssuranceAdmonition({ if (aa.state.access === aa.Access.Full) return null if (aa.state.error === 'config') { - return + return } return ( diff --git a/src/components/ageAssurance/AgeAssuranceDismissibleNotice.tsx b/src/components/ageAssurance/AgeAssuranceDismissibleNotice.tsx index 934ac8d14a..14c7ed300f 100644 --- a/src/components/ageAssurance/AgeAssuranceDismissibleNotice.tsx +++ b/src/components/ageAssurance/AgeAssuranceDismissibleNotice.tsx @@ -5,6 +5,7 @@ import {useLingui} from '@lingui/react' import {Nux, useNux, useSaveNux} from '#/state/queries/nuxs' import {atoms as a, type ViewStyleProp} from '#/alf' import {AgeAssuranceAdmonition} from '#/components/ageAssurance/AgeAssuranceAdmonition' +import {AgeAssuranceConfigUnavailableError} from '#/components/ageAssurance/AgeAssuranceErrors' import {useAgeAssuranceCopy} from '#/components/ageAssurance/useAgeAssuranceCopy' import {Button, ButtonIcon} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' @@ -26,33 +27,37 @@ export function AgeAssuranceDismissibleNotice({style}: ViewStyleProp & {}) { return ( - - {copy.notice} + {aa.state.error === 'config' ? ( + + ) : ( + + {copy.notice} - - + + + )} ) } diff --git a/src/components/ageAssurance/AgeAssuranceErrors.tsx b/src/components/ageAssurance/AgeAssuranceErrors.tsx index 3c35ca7b2e..628153f084 100644 --- a/src/components/ageAssurance/AgeAssuranceErrors.tsx +++ b/src/components/ageAssurance/AgeAssuranceErrors.tsx @@ -1,16 +1,37 @@ -import {Trans} from '@lingui/macro' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' import {type ViewStyleProp} from '#/alf' -import {Admonition} from '#/components/Admonition' +import * as Admonition from '#/components/Admonition' +import {ButtonIcon, ButtonText} from '#/components/Button' +import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as RetryIcon} from '#/components/icons/ArrowRotate' +import {refetchConfig} from '#/ageAssurance/data' export function AgeAssuranceConfigUnavailableError(props: ViewStyleProp) { + const {_} = useLingui() return ( - - - We were unable to load age assurance configuration for your region, - probably due to a network error. Some content and features may be - unavailable temporarily. Please try again later. - - + + + + + + + We were unable to load the age assurance configuration for your + region, probably due to a network error. Some content and features + may be unavailable temporarily. Please try again later. + + + + refetchConfig().catch(() => {})}> + + Retry + + + + + ) }