about summary refs log tree commit diff
path: root/src/screens/Signup/StepInfo/Policies.tsx
blob: 36de08f6e3df38644de86f4d0f7f73ac339d3907 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import {type ReactElement} from 'react'
import {View} from 'react-native'
import {type ComAtprotoServerDescribeServer} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {webLinks} from '#/lib/constants'
import {useGate} from '#/lib/statsig/statsig'
import {atoms as a, useTheme} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {InlineLinkText} from '#/components/Link'
import {Text} from '#/components/Typography'

function CommunityGuidelinesNotice({}: {}) {
  const {_} = useLingui()
  const gate = useGate()

  if (gate('disable_onboarding_policy_update_notice')) return null

  return (
    <View style={[a.pt_xs]}>
      <Admonition type="tip">
        <Trans>
          You also agree to{' '}
          <InlineLinkText
            label={_(msg`Bluesky's Community Guidelines`)}
            to={webLinks.communityDeprecated}>
            Blueskys Community Guidelines
          </InlineLinkText>
          . An{' '}
          <InlineLinkText
            label={_(msg`Bluesky's Updated Community Guidelines`)}
            to={webLinks.community}>
            updated version of our Community Guidelines
          </InlineLinkText>{' '}
          will take effect on October 15th.
        </Trans>
      </Admonition>
    </View>
  )
}

export const Policies = ({
  serviceDescription,
  needsGuardian,
  under13,
}: {
  serviceDescription: ComAtprotoServerDescribeServer.OutputSchema
  needsGuardian: boolean
  under13: boolean
}) => {
  const t = useTheme()
  const {_} = useLingui()

  if (!serviceDescription) {
    return <View />
  }

  const tos = validWebLink(serviceDescription.links?.termsOfService)
  const pp = validWebLink(serviceDescription.links?.privacyPolicy)

  if (!tos && !pp) {
    return (
      <View style={[a.gap_sm]}>
        <Admonition type="info">
          <Trans>
            This service has not provided terms of service or a privacy policy.
          </Trans>
        </Admonition>
        <CommunityGuidelinesNotice />
      </View>
    )
  }

  let els: ReactElement
  if (tos && pp) {
    els = (
      <Trans>
        By creating an account you agree to the{' '}
        <InlineLinkText
          label={_(msg`Read the Bluesky Terms of Service`)}
          key="tos"
          to={tos}>
          Terms of Service
        </InlineLinkText>{' '}
        and{' '}
        <InlineLinkText
          label={_(msg`Read the Bluesky Privacy Policy`)}
          key="pp"
          to={pp}>
          Privacy Policy
        </InlineLinkText>
        .
      </Trans>
    )
  } else if (tos) {
    els = (
      <Trans>
        By creating an account you agree to the{' '}
        <InlineLinkText
          label={_(msg`Read the Bluesky Terms of Service`)}
          key="tos"
          to={tos}>
          Terms of Service
        </InlineLinkText>
        .
      </Trans>
    )
  } else if (pp) {
    els = (
      <Trans>
        By creating an account you agree to the{' '}
        <InlineLinkText
          label={_(msg`Read the Bluesky Privacy Policy`)}
          key="pp"
          to={pp}>
          Privacy Policy
        </InlineLinkText>
        .
      </Trans>
    )
  } else {
    return null
  }

  return (
    <View style={[a.gap_sm]}>
      {els ? (
        <Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>
          {els}
        </Text>
      ) : null}

      {under13 ? (
        <Admonition type="error">
          <Trans>
            You must be 13 years of age or older to create an account.
          </Trans>
        </Admonition>
      ) : needsGuardian ? (
        <Admonition type="warning">
          <Trans>
            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.
          </Trans>
        </Admonition>
      ) : undefined}

      <CommunityGuidelinesNotice />
    </View>
  )
}

function validWebLink(url?: string): string | undefined {
  return url && (url.startsWith('http://') || url.startsWith('https://'))
    ? url
    : undefined
}