11import { CustomProfileFieldType } from '@logto/schemas' ;
22import { type ReactNode } from 'react' ;
33import { useFormContext , Controller } from 'react-hook-form' ;
4- import { useTranslation } from 'react-i18next' ;
4+ import { Trans , useTranslation } from 'react-i18next' ;
55
66import CheckboxIcon from '@/assets/icons/field-type-checkbox.svg?react' ;
77import DateIcon from '@/assets/icons/field-type-date.svg?react' ;
@@ -14,6 +14,7 @@ import FormField from '@/ds-components/FormField';
1414import Select from '@/ds-components/Select' ;
1515import Switch from '@/ds-components/Switch' ;
1616import TextInput from '@/ds-components/TextInput' ;
17+ import TextLink from '@/ds-components/TextLink' ;
1718import Textarea from '@/ds-components/Textarea' ;
1819
1920import { type ProfileFieldForm } from '../../CollectUserProfile/types' ;
@@ -109,6 +110,7 @@ function ProfileFieldPartSubForm({ index }: Props) {
109110 < FormField
110111 isRequired = { ! isBuiltInFieldName }
111112 title = "sign_in_exp.custom_profile_fields.details.label"
113+ tip = { t ( 'sign_in_exp.custom_profile_fields.details.label_tooltip' ) }
112114 >
113115 < Controller
114116 name = { `${ fieldPrefix } label` }
@@ -117,7 +119,7 @@ function ProfileFieldPartSubForm({ index }: Props) {
117119 required :
118120 ! isBuiltInFieldName &&
119121 t ( 'errors.required_field_missing' , {
120- field : t ( 'sign_in_exp.custom_profile_fields.details.label' ) ,
122+ field : t ( 'sign_in_exp.custom_profile_fields.details.label' ) . toLowerCase ( ) ,
121123 } ) ,
122124 } }
123125 render = { ( { field : { value, onChange } } ) => {
@@ -128,14 +130,22 @@ function ProfileFieldPartSubForm({ index }: Props) {
128130 error = { formErrors ?. label ?. message }
129131 placeholder = { t ( 'sign_in_exp.custom_profile_fields.details.label_placeholder' ) }
130132 value = { value || fallbackValue }
133+ description = {
134+ < Trans components = { { a : < TextLink to = "/sign-in-experience/content" /> } } >
135+ { t ( 'sign_in_exp.custom_profile_fields.details.label_tip' ) }
136+ </ Trans >
137+ }
131138 onChange = { onChange }
132139 />
133140 ) ;
134141 } }
135142 />
136143 </ FormField >
137144 { type !== CustomProfileFieldType . Checkbox && (
138- < FormField title = "sign_in_exp.custom_profile_fields.details.placeholder" >
145+ < FormField
146+ title = "sign_in_exp.custom_profile_fields.details.placeholder"
147+ tip = { t ( 'sign_in_exp.custom_profile_fields.details.placeholder_tooltip' ) }
148+ >
139149 < TextInput
140150 { ...register ( `${ fieldPrefix } placeholder` ) }
141151 error = { formErrors ?. placeholder ?. message }
@@ -144,7 +154,10 @@ function ProfileFieldPartSubForm({ index }: Props) {
144154 </ FormField >
145155 ) }
146156 { type !== CustomProfileFieldType . Checkbox && (
147- < FormField title = "sign_in_exp.custom_profile_fields.details.description" >
157+ < FormField
158+ title = "sign_in_exp.custom_profile_fields.details.description"
159+ tip = { t ( 'sign_in_exp.custom_profile_fields.details.description_tooltip' ) }
160+ >
148161 < TextInput
149162 { ...register ( `${ fieldPrefix } description` ) }
150163 error = { formErrors ?. description ?. message }
@@ -157,10 +170,11 @@ function ProfileFieldPartSubForm({ index }: Props) {
157170 < Textarea
158171 { ...register ( `${ fieldPrefix } options` , {
159172 required : t ( 'errors.required_field_missing' , {
160- field : t ( 'sign_in_exp.custom_profile_fields.details.options' ) ,
173+ field : t ( 'sign_in_exp.custom_profile_fields.details.options' ) . toLowerCase ( ) ,
161174 } ) ,
162175 } ) }
163176 error = { formErrors ?. options ?. message }
177+ description = { t ( 'sign_in_exp.custom_profile_fields.details.options_tip' ) }
164178 placeholder = { t ( 'sign_in_exp.custom_profile_fields.details.options_placeholder' ) }
165179 rows = { 5 }
166180 />
@@ -181,7 +195,7 @@ function ProfileFieldPartSubForm({ index }: Props) {
181195 < TextInput
182196 { ...register ( `${ fieldPrefix } format` , {
183197 required : t ( 'errors.required_field_missing' , {
184- field : t ( 'sign_in_exp.custom_profile_fields.details.regex' ) ,
198+ field : t ( 'sign_in_exp.custom_profile_fields.details.regex' ) . toLowerCase ( ) ,
185199 } ) ,
186200 } ) }
187201 error = { formErrors ?. format ?. message }
0 commit comments