@@ -58,8 +58,18 @@ const VirtualAccOpening = (() => {
5858 } ;
5959
6060 const handleWebsiteStatus = ( website_status = { } , $residence ) => {
61- const email_consent_container = $ ( '#consent_checkbox' ) ;
62- const consent_checkbox = $ ( '#email_consent' ) ;
61+ const $email_consent_container = $ ( '#consent_checkbox' ) ;
62+
63+ const handleEmailConsent = ( ) => {
64+ const updated_selected_value = $ ( '#residence' ) . val ( ) ;
65+ const eu_country = isEuCountrySelected ( updated_selected_value ) ;
66+ if ( eu_country ) {
67+ $email_consent_container . setVisibility ( 1 ) ;
68+ } else {
69+ $email_consent_container . setVisibility ( 0 ) ;
70+ }
71+ } ;
72+
6373 if ( ! website_status || Utility . isEmptyObject ( website_status ) ) return ;
6474 const clients_country = website_status . clients_country ;
6575
@@ -75,25 +85,10 @@ const VirtualAccOpening = (() => {
7585 } ,
7686 } )
7787 . setVisibility ( 1 ) ;
78-
88+
7989 const residence_dropdown = $ ( '#residence' ) ;
80- if ( isEuCountrySelected ( residence_dropdown . val ( ) ) ) {
81- consent_checkbox . removeClass ( 'hidden-consent-checkbox' ) ;
82- email_consent_container . removeClass ( 'email-consent-container' ) ;
83- } else {
84- consent_checkbox . addClass ( 'hidden-consent-checkbox' ) ;
85- }
86- residence_dropdown . on ( 'change' , ( ) => {
87- const updated_selected_value = $ ( '#residence' ) . val ( ) ;
88- const eu_country = isEuCountrySelected ( updated_selected_value ) ;
89- if ( eu_country ) {
90- consent_checkbox . removeClass ( 'hidden-consent-checkbox' ) ;
91- email_consent_container . removeClass ( 'email-consent-container' ) ;
92- } else {
93- consent_checkbox . addClass ( 'hidden-consent-checkbox' ) ;
94- email_consent_container . addClass ( 'email-consent-container' ) ;
95- }
96- } ) ;
90+ handleEmailConsent ( ) ;
91+ residence_dropdown . on ( 'change' , handleEmailConsent ) ;
9792 } ;
9893
9994 const bindValidation = ( ) => {
@@ -185,7 +180,7 @@ const VirtualAccOpening = (() => {
185180 return urlFor ( 'new_account/welcome_onboarding' ) ;
186181 }
187182 if ( residence === 'au' ) return urlFor ( 'user/metatrader' ) ;
188-
183+
189184 return urlFor ( 'new_account/welcome' ) ;
190185 } ;
191186 const showFormError = ( message , url ) => {
0 commit comments