@@ -6,6 +6,7 @@ import { EmailField } from '~/common/email-field';
6
6
import { FirstNameField } from '~/common/first-name-field' ;
7
7
import { GlobalError } from '~/common/global-error' ;
8
8
import { LastNameField } from '~/common/last-name-field' ;
9
+ import { LegalAcceptedField } from '~/common/legal-accepted' ;
9
10
import { PasswordField } from '~/common/password-field' ;
10
11
import { PhoneNumberField } from '~/common/phone-number-field' ;
11
12
import { RouterLink } from '~/common/router-link' ;
@@ -14,6 +15,7 @@ import { LOCALIZATION_NEEDED } from '~/constants/localizations';
14
15
import { useAttributes } from '~/hooks/use-attributes' ;
15
16
import { useCard } from '~/hooks/use-card' ;
16
17
import { useDevModeWarning } from '~/hooks/use-dev-mode-warning' ;
18
+ import { useEnvironment } from '~/hooks/use-environment' ;
17
19
import { useLocalizations } from '~/hooks/use-localizations' ;
18
20
import { useOptions } from '~/hooks/use-options' ;
19
21
import { Button } from '~/primitives/button' ;
@@ -24,11 +26,23 @@ export function SignUpContinue() {
24
26
const clerk = useClerk ( ) ;
25
27
const { signInUrl } = useOptions ( ) ;
26
28
const { t } = useLocalizations ( ) ;
29
+ const environment = useEnvironment ( ) ;
30
+ const { client } = useClerk ( ) ;
31
+ const { missingFields } = client . signUp ;
27
32
const { enabled : firstNameEnabled , required : firstNameRequired } = useAttributes ( 'first_name' ) ;
28
33
const { enabled : lastNameEnabled , required : lastNameRequired } = useAttributes ( 'last_name' ) ;
29
34
const { enabled : usernameEnabled , required : usernameRequired } = useAttributes ( 'username' ) ;
30
35
const { enabled : phoneNumberEnabled , required : phoneNumberRequired } = useAttributes ( 'phone_number' ) ;
31
36
const { enabled : passwordEnabled , required : passwordRequired } = useAttributes ( 'password' ) ;
37
+ const legalConsentEnabled = environment . userSettings . signUp . legal_consent_enabled ;
38
+ const legalConsentMissing = missingFields . includes ( 'legal_accepted' ) ;
39
+ const showFirstName = firstNameEnabled && firstNameRequired && missingFields . includes ( 'first_name' ) ;
40
+ const showLastName = lastNameEnabled && lastNameRequired && missingFields . includes ( 'last_name' ) ;
41
+ const showUserName = usernameEnabled && usernameRequired && missingFields . includes ( 'username' ) ;
42
+ const showPhoneNumber = phoneNumberEnabled && phoneNumberRequired && missingFields . includes ( 'phone_number' ) ;
43
+ const showPassword = passwordEnabled && passwordRequired && missingFields . includes ( 'password' ) ;
44
+ const showEmail = missingFields . includes ( 'email_address' ) ;
45
+ const showLegalConsent = legalConsentEnabled && legalConsentMissing ;
32
46
const isDev = useDevModeWarning ( ) ;
33
47
const { logoProps, footerProps } = useCard ( ) ;
34
48
@@ -55,7 +69,7 @@ export function SignUpContinue() {
55
69
56
70
< Card . Body >
57
71
< div className = 'flex flex-col gap-y-4' >
58
- { firstNameEnabled && lastNameEnabled ? (
72
+ { showFirstName && showLastName ? (
59
73
< div className = 'flex gap-4 empty:hidden' >
60
74
< FirstNameField
61
75
required = { firstNameRequired }
@@ -68,30 +82,32 @@ export function SignUpContinue() {
68
82
</ div >
69
83
) : null }
70
84
71
- { usernameEnabled ? (
85
+ { showUserName ? (
72
86
< UsernameField
73
87
required = { usernameRequired }
74
88
disabled = { isGlobalLoading }
75
89
/>
76
90
) : null }
77
91
78
- { phoneNumberEnabled ? (
92
+ { showPhoneNumber ? (
79
93
< PhoneNumberField
80
94
required = { phoneNumberRequired }
81
95
disabled = { isGlobalLoading }
82
96
/>
83
97
) : null }
84
98
85
- < EmailField disabled = { isGlobalLoading } />
99
+ { showEmail && < EmailField disabled = { isGlobalLoading } /> }
86
100
87
- { passwordEnabled && passwordRequired ? (
101
+ { showPassword ? (
88
102
< PasswordField
89
103
validatePassword
90
104
label = { t ( 'formFieldLabel__password' ) }
91
105
required = { passwordRequired }
92
106
disabled = { isGlobalLoading }
93
107
/>
94
108
) : null }
109
+
110
+ { showLegalConsent && < LegalAcceptedField /> }
95
111
</ div >
96
112
</ Card . Body >
97
113
< Card . Actions >
0 commit comments