Provide age-restricted viewers the option to delete their account (#10041)
This commit is contained in:
@@ -12,6 +12,8 @@ import {
|
|||||||
import {dateDiff, useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
import {dateDiff, useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
||||||
import {useIsBirthdateUpdateAllowed} from '#/state/birthdate'
|
import {useIsBirthdateUpdateAllowed} from '#/state/birthdate'
|
||||||
import {useSessionApi} from '#/state/session'
|
import {useSessionApi} from '#/state/session'
|
||||||
|
import {DeactivateAccountDialog} from '#/screens/Settings/components/DeactivateAccountDialog'
|
||||||
|
import {DeleteAccountDialog} from '#/screens/Settings/components/DeleteAccountDialog'
|
||||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||||
import {Admonition} from '#/components/Admonition'
|
import {Admonition} from '#/components/Admonition'
|
||||||
import {AgeAssuranceAppealDialog} from '#/components/ageAssurance/AgeAssuranceAppealDialog'
|
import {AgeAssuranceAppealDialog} from '#/components/ageAssurance/AgeAssuranceAppealDialog'
|
||||||
@@ -49,6 +51,8 @@ export function NoAccessScreen() {
|
|||||||
const {gtPhone} = useBreakpoints()
|
const {gtPhone} = useBreakpoints()
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
const birthdateControl = useDialogControl()
|
const birthdateControl = useDialogControl()
|
||||||
|
const deactivateAccountControl = useDialogControl()
|
||||||
|
const deleteAccountControl = useDialogControl()
|
||||||
const {data} = useAgeAssuranceDataContext()
|
const {data} = useAgeAssuranceDataContext()
|
||||||
const region = useAgeAssuranceRegionConfig()
|
const region = useAgeAssuranceRegionConfig()
|
||||||
const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
|
const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
|
||||||
@@ -71,6 +75,7 @@ export function NoAccessScreen() {
|
|||||||
hasDeclaredAge,
|
hasDeclaredAge,
|
||||||
canUpdateBirthday,
|
canUpdateBirthday,
|
||||||
})
|
})
|
||||||
|
// TODO This can be cleaned up with useEffectEvent once we're on 19.2
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@@ -234,18 +239,38 @@ export function NoAccessScreen() {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<View style={[a.pt_lg, a.gap_xl]}>
|
<View style={[a.pt_lg, a.gap_xl, {maxWidth: 280}]}>
|
||||||
<Logo width={120} textFill={t.atoms.text.color} />
|
<Logo width={120} textFill={t.atoms.text.color} />
|
||||||
<Text style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
<Text
|
||||||
|
style={[
|
||||||
|
a.text_sm,
|
||||||
|
a.italic,
|
||||||
|
a.leading_snug,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
To log out,{' '}
|
To log out,{' '}
|
||||||
<SimpleInlineLinkText
|
<SimpleInlineLinkText
|
||||||
label={_(msg`Click here to log out`)}
|
label={_(msg`Click here to log out`)}
|
||||||
{...createStaticClick(() => {
|
{...createStaticClick(() => {
|
||||||
onPressLogout()
|
onPressLogout()
|
||||||
})}>
|
})}
|
||||||
|
style={[a.italic]}>
|
||||||
click here
|
click here
|
||||||
</SimpleInlineLinkText>
|
</SimpleInlineLinkText>
|
||||||
|
. Or if you’d prefer, you can{' '}
|
||||||
|
<SimpleInlineLinkText
|
||||||
|
label={_(msg`Click here to delete your account`)}
|
||||||
|
{...createStaticClick(() => {
|
||||||
|
ax.metric(
|
||||||
|
'ageAssurance:noAccessScreen:openDeleteAccountDialog',
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
deleteAccountControl.open()
|
||||||
|
})}
|
||||||
|
style={[a.italic]}>
|
||||||
|
delete your account
|
||||||
|
</SimpleInlineLinkText>
|
||||||
.
|
.
|
||||||
</Trans>
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
@@ -255,6 +280,11 @@ export function NoAccessScreen() {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<BirthDateSettingsDialog control={birthdateControl} />
|
<BirthDateSettingsDialog control={birthdateControl} />
|
||||||
|
<DeactivateAccountDialog control={deactivateAccountControl} />
|
||||||
|
<DeleteAccountDialog
|
||||||
|
control={deleteAccountControl}
|
||||||
|
deactivateDialogControl={deactivateAccountControl}
|
||||||
|
/>
|
||||||
|
|
||||||
{/*
|
{/*
|
||||||
* While this blocking overlay is up, other dialogs in the shell
|
* While this blocking overlay is up, other dialogs in the shell
|
||||||
|
|||||||
@@ -847,6 +847,7 @@ export type Events = {
|
|||||||
canUpdateBirthday: boolean
|
canUpdateBirthday: boolean
|
||||||
}
|
}
|
||||||
'ageAssurance:noAccessScreen:openBirthdateDialog': {}
|
'ageAssurance:noAccessScreen:openBirthdateDialog': {}
|
||||||
|
'ageAssurance:noAccessScreen:openDeleteAccountDialog': {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Specifically for the `BlockedGeoOverlay`
|
* Specifically for the `BlockedGeoOverlay`
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export function useIsBirthdateUpdateAllowed() {
|
|||||||
])
|
])
|
||||||
if (!lastUpdated) return true
|
if (!lastUpdated) return true
|
||||||
const lastUpdatedDate = new Date(lastUpdated)
|
const lastUpdatedDate = new Date(lastUpdated)
|
||||||
|
// eslint-disable-next-line react-hooks/purity
|
||||||
const diffMs = Date.now() - lastUpdatedDate.getTime()
|
const diffMs = Date.now() - lastUpdatedDate.getTime()
|
||||||
const diffHours = diffMs / (1000 * 60 * 60)
|
const diffHours = diffMs / (1000 * 60 * 60)
|
||||||
return diffHours >= BIRTHDATE_DELAY_HOURS
|
return diffHours >= BIRTHDATE_DELAY_HOURS
|
||||||
@@ -66,7 +67,7 @@ export function useBirthdateMutation() {
|
|||||||
* Also patch the age assurance other required data with the new
|
* Also patch the age assurance other required data with the new
|
||||||
* birthdate, which may change the user's age assurance access level.
|
* birthdate, which may change the user's age assurance access level.
|
||||||
*/
|
*/
|
||||||
patchOtherRequiredData({birthdate: bday})
|
void patchOtherRequiredData({birthdate: bday})
|
||||||
snoozeBirthdateUpdateAllowedForDid(agent.sessionManager.did!)
|
snoozeBirthdateUpdateAllowedForDid(agent.sessionManager.did!)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user