@@ -22,6 +22,7 @@ type TEmploymentTaxDetailsContainerProps = {
22
22
handleChange : ( value : string ) => void ;
23
23
tin_validation_config : TinValidations ;
24
24
id ?: string ;
25
+ should_focus_fields ?: boolean ;
25
26
} ;
26
27
27
28
const EmploymentTaxDetailsContainer = observer (
@@ -31,12 +32,15 @@ const EmploymentTaxDetailsContainer = observer(
31
32
should_display_long_message,
32
33
tin_validation_config,
33
34
handleChange,
35
+ should_focus_fields,
34
36
} : TEmploymentTaxDetailsContainerProps ) => {
35
37
const { values, setFieldValue, touched, errors, setValues } = useFormikContext < FormikValues > ( ) ;
36
38
const { isDesktop } = useDevice ( ) ;
37
39
const { data : residence_list } = useResidenceList ( ) ;
38
40
const { client } = useStore ( ) ;
39
41
42
+ const { is_virtual, account_settings } = client ;
43
+
40
44
const [ is_tax_residence_popover_open , setIsTaxResidencePopoverOpen ] = useState ( false ) ;
41
45
const [ is_tin_popover_open , setIsTinPopoverOpen ] = useState ( false ) ;
42
46
@@ -117,22 +121,26 @@ const EmploymentTaxDetailsContainer = observer(
117
121
118
122
const { tin_employment_status_bypass } = tin_validation_config ;
119
123
120
- const is_tin_required = ! client . is_virtual && ! tin_employment_status_bypass ?. includes ( values . employment_status ) ;
124
+ const is_tin_required = ! is_virtual && ! tin_employment_status_bypass ?. includes ( values . employment_status ) ;
121
125
122
126
const should_show_no_tax_details_checkbox =
123
127
( tin_employment_status_bypass ?. includes ( values . employment_status ) && ! ! values . tax_residence ) ||
124
128
Boolean ( values . tin_skipped ) ;
125
129
126
130
const should_show_tax_confirm_checkbox =
127
- ! client . account_settings . tax_identification_number || touched . tax_identification_number ;
131
+ ! account_settings . tax_identification_number || touched . tax_identification_number ;
128
132
129
133
const isFieldDisabled = ( field_name : string ) => isFieldImmutable ( field_name , editable_fields ) ;
130
134
131
135
return (
132
136
< div id = { 'employment-tax-section' } >
133
- < EmploymentStatusField required is_disabled = { isFieldDisabled ( 'employment_status' ) } />
137
+ < EmploymentStatusField
138
+ required
139
+ is_disabled = { isFieldDisabled ( 'employment_status' ) }
140
+ fieldFocused = { should_focus_fields && ! account_settings . employment_status }
141
+ />
134
142
135
- { ! client . account_settings . tax_identification_number && should_show_no_tax_details_checkbox && (
143
+ { ! account_settings . tax_identification_number && should_show_no_tax_details_checkbox && (
136
144
< Checkbox
137
145
name = 'tin_skipped'
138
146
className = 'employment_tax_detail_field-checkbox'
@@ -164,6 +172,9 @@ const EmploymentTaxDetailsContainer = observer(
164
172
setIsTaxResidencePopoverOpen = { setIsTaxResidencePopoverOpen }
165
173
setIsTinPopoverOpen = { setIsTinPopoverOpen }
166
174
required = { ( should_display_long_message && ! values . tin_skipped ) || is_tin_required }
175
+ fieldFocused = {
176
+ should_focus_fields && ( ! account_settings . tax_residence || ! account_settings . residence )
177
+ }
167
178
/>
168
179
</ div >
169
180
< div ref = { tin_ref } className = 'account-form__fieldset' >
@@ -173,6 +184,12 @@ const EmploymentTaxDetailsContainer = observer(
173
184
setIsTinPopoverOpen = { setIsTinPopoverOpen }
174
185
setIsTaxResidencePopoverOpen = { setIsTaxResidencePopoverOpen }
175
186
required = { ( should_display_long_message && ! values . tin_skipped ) || is_tin_required }
187
+ fieldFocused = {
188
+ should_focus_fields &&
189
+ values . employment_status &&
190
+ ! values . tin_skipped &&
191
+ ( should_display_long_message || is_tin_required )
192
+ }
176
193
/>
177
194
</ div >
178
195
{ should_show_tax_confirm_checkbox && (
0 commit comments