Decompose, add docblocks

This commit is contained in:
Eric Bailey
2025-07-15 17:13:13 -05:00
parent 97a056fbeb
commit f9449d23fa
3 changed files with 26 additions and 17 deletions
+17 -8
View File
@@ -7,12 +7,21 @@ import {usePreferencesQuery} from '#/state/queries/preferences'
const logger = Logger.create(Logger.Context.AgeAssurance)
type AgeAssurance = {
isReady: boolean
declaredAge: number | undefined
isDeclaredUnderage: boolean
type AgeAssurance = ReturnType<typeof useAgeAssuranceContext> & {
/**
* Indicates the user is age restricted based on the requirements of their
* region, and their server-provided age assurance status. Does not factor in
* the user's declared age.
*/
isAgeRestricted: boolean
assurance: ReturnType<typeof useAgeAssuranceContext>
/**
* The age the user has declared in their preferences, if any.
*/
declaredAge: number | undefined
/**
* Indicates whether the user has declared an age under 18.
*/
isDeclaredUnderage: boolean
}
/**
@@ -32,11 +41,11 @@ export function useAgeAssurance(): AgeAssurance {
const isDeclaredUnderage = (declaredAge || 0) < 18
const state: AgeAssurance = {
isReady,
status: ctx.status,
lastInitiatedAt: ctx.lastInitiatedAt,
isAgeRestricted,
declaredAge,
isDeclaredUnderage,
isAgeRestricted,
assurance: ctx,
}
logger.debug(`state`, state)
return state