Include a notice during account creation for under-18 users (#927)

zio/stable
Paul Frazee 2023-06-30 11:34:52 -05:00 committed by GitHub
parent c72e24f841
commit 48844aa4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -31,13 +31,21 @@ export class CreateAccountModel {
makeAutoObservable(this, {}, {autoBind: true}) makeAutoObservable(this, {}, {autoBind: true})
} }
get isAge13() {
return getAge(this.birthDate) >= 13
}
get isAge18() {
return getAge(this.birthDate) >= 18
}
// form state controls // form state controls
// = // =
next() { next() {
this.error = '' this.error = ''
if (this.step === 2) { if (this.step === 2) {
if (getAge(this.birthDate) < 13) { if (!this.isAge13) {
this.error = this.error =
'Unfortunately, you do not meet the requirements to create an account.' 'Unfortunately, you do not meet the requirements to create an account.'
return return

View File

@ -12,8 +12,10 @@ import {usePalette} from 'lib/hooks/usePalette'
export const Policies = ({ export const Policies = ({
serviceDescription, serviceDescription,
needsGuardian,
}: { }: {
serviceDescription: ServiceDescription serviceDescription: ServiceDescription
needsGuardian: boolean
}) => { }) => {
const pal = usePalette('default') const pal = usePalette('default')
if (!serviceDescription) { if (!serviceDescription) {
@ -73,6 +75,12 @@ export const Policies = ({
<Text style={pal.textLight}> <Text style={pal.textLight}>
By creating an account you agree to the {els}. By creating an account you agree to the {els}.
</Text> </Text>
{needsGuardian && (
<Text style={[pal.textLight, s.bold]}>
If you are not yet an adult according to the laws of your country,
your parent or legal guardian must read these Terms on your behalf.
</Text>
)}
</View> </View>
) )
} }
@ -85,8 +93,7 @@ function validWebLink(url?: string): string | undefined {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
policies: { policies: {
flexDirection: 'row', gap: 8,
alignItems: 'flex-start',
}, },
errorIcon: { errorIcon: {
borderWidth: 1, borderWidth: 1,

View File

@ -116,7 +116,10 @@ export const Step2 = observer(({model}: {model: CreateAccountModel}) => {
</View> </View>
{model.serviceDescription && ( {model.serviceDescription && (
<Policies serviceDescription={model.serviceDescription} /> <Policies
serviceDescription={model.serviceDescription}
needsGuardian={!model.isAge18}
/>
)} )}
</> </>
)} )}