Decompose, add docblocks
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user