This commit is contained in:
Eric Bailey
2025-07-15 13:10:53 -05:00
parent 259589024d
commit 5701990606
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -34,6 +34,11 @@ const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
refetch: () => Promise.resolve(),
})
/**
* Low-level provider for fetching age assurance state on app load. Do not add
* any other data fetching in here to avoid complications and reduced
* performance.
*/
export function Provider({children}: {children: React.ReactNode}) {
const agent = useAgent()
const {geolocation} = useGeolocation()
@@ -124,6 +129,10 @@ export function Provider({children}: {children: React.ReactNode}) {
)
}
/**
* Access to low-level AA state. Prefer using {@link useAgeInfo} for a
* more user-friendly interface.
*/
export function useAgeAssuranceContext() {
return useContext(AgeAssuranceContext)
}
+5
View File
@@ -3,6 +3,11 @@ import {useMemo} from 'react'
import {useAgeAssuranceContext} from '#/state/age-assurance'
import {usePreferencesQuery} from '#/state/queries/preferences'
/**
* Computed age information based on age assurance status and the user's
* declared age. Use this instead of {@link useAgeAssuranceContext} to get a
* more user-friendly interface.
*/
export function useAgeInfo() {
const ctx = useAgeAssuranceContext()
const {isFetched: preferencesLoaded, data: preferences} =