Age Assurance V2 (#9479)

* Age Assurance V2

* Tighten up test

* Add todos for sdk migration

* Align RQ versions

* Use useEffect for side effect

* Improve effects, memoize

* Standarize on birthdate

* Copy feedback

* Copilot

* Add support link

* Reove double ..

* Cleanup

* Remove redirect dialog

* Cleanup todos, add comments

* Update splash in main template too

* Mock some stuff

* Exhaustive checks

Co-authored-by: Samuel Newman <mozzius@protonmail.com>

* Exhaustive checks

Co-authored-by: Samuel Newman <mozzius@protonmail.com>

* Small fix to bday handling

* Add comment

* onboarding style tweak

sneaking this in sorry!

* rm unreachable breaks

* Put useIntentHandler back on web

* Remove misleading success set

* Align on birthdate

---------

Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
Eric Bailey
2025-12-04 15:20:00 -06:00
committed by GitHub
parent 7735183af4
commit c4aef9f668
91 changed files with 3016 additions and 1799 deletions
+65
View File
@@ -0,0 +1,65 @@
import {
createContext,
type ReactNode,
useContext,
useEffect,
useMemo,
} from 'react'
import {useSyncDeviceGeolocationOnStartup} from '#/geolocation/device'
import {useGeolocationServiceResponse} from '#/geolocation/service'
import {type Geolocation} from '#/geolocation/types'
import {mergeGeolocations} from '#/geolocation/util'
import {device, useStorage} from '#/storage'
export {useRequestDeviceGeolocation} from '#/geolocation/device'
export {resolve} from '#/geolocation/service'
export * from '#/geolocation/types'
const GeolocationContext = createContext<Geolocation>({
countryCode: undefined,
regionCode: undefined,
})
const DeviceGeolocationAPIContext = createContext<{
setDeviceGeolocation(deviceGeolocation: Geolocation): void
}>({
setDeviceGeolocation: () => {},
})
export function useGeolocation() {
return useContext(GeolocationContext)
}
export function useDeviceGeolocationApi() {
return useContext(DeviceGeolocationAPIContext)
}
export function Provider({children}: {children: ReactNode}) {
const geolocationService = useGeolocationServiceResponse()
const [deviceGeolocation, setDeviceGeolocation] = useStorage(device, [
'deviceGeolocation',
])
const geolocation = useMemo(() => {
return mergeGeolocations(deviceGeolocation, geolocationService)
}, [deviceGeolocation, geolocationService])
useEffect(() => {
/**
* Save this for out-of-band-reads during future cold starts of the app.
* Needs to be available for the data prefetching we do on boot.
*/
device.set(['mergedGeolocation'], geolocation)
}, [geolocation])
useSyncDeviceGeolocationOnStartup(setDeviceGeolocation)
return (
<GeolocationContext.Provider value={geolocation}>
<DeviceGeolocationAPIContext.Provider
value={useMemo(() => ({setDeviceGeolocation}), [setDeviceGeolocation])}>
{children}
</DeviceGeolocationAPIContext.Provider>
</GeolocationContext.Provider>
)
}