@@ -2,36 +2,23 @@ import $banner from "text!./banners.html";
22import liveapi from "../websockets/binary_websockets" ;
33import "css!banners/banners.css" ;
44
5- export const isEuCountry = ( clients_country , landing_company ) => {
6- const eu_shortcode_regex = new RegExp ( "^(maltainvest|malta|iom)$" ) ;
7- const eu_excluded_regex = new RegExp ( "^mt$" ) ;
8- const financial_shortcode =
9- ( landing_company && landing_company . financial_company )
10- ? landing_company . financial_company . shortcode
11- : "" ;
12- const gaming_shortcode =
13- ( landing_company && landing_company . gaming_company )
14- ? landing_company . gaming_company . shortcode
15- : "" ;
165
17- return financial_shortcode || gaming_shortcode
18- ? eu_shortcode_regex . test ( financial_shortcode ) ||
19- eu_shortcode_regex . test ( gaming_shortcode )
20- : eu_excluded_regex . test ( clients_country ) ;
6+ const shouldShowBanner = ( auth ) => {
7+ const has_mf = auth . account_list . filter ( item => item . landing_company_name === 'maltainvest' ) . length ;
8+ const has_mlt = auth . account_list . filter ( item => item . landing_company_name === 'malta' ) . length ;
9+ const has_iom = auth . account_list . filter ( item => item . landing_company_name === 'iom' ) . length ;
10+ const current_loginId = local_storage . get ( 'authorize' ) . loginid ;
11+ const getLoginId = loginids ( ) . filter ( item => item . id === current_loginId ) ;
12+ const is_mf = getLoginId [ 0 ] . is_mf ;
13+ const is_virtual = getLoginId [ 0 ] . is_virtual ;
14+ if ( is_mf ) {
15+ return true ;
16+ } else if ( is_virtual && has_mf && ! has_iom && ! has_mlt ) {
17+ return true ;
18+ }
19+ return false ;
2120} ;
2221
23- export const isMFCountry = ( landing_company ) => {
24- const mf_shortcode_regex = new RegExp ( "^(maltainvest)$" ) ;
25- const gaming_shortcode =
26- ( landing_company && landing_company . gaming_company )
27- ? landing_company . gaming_company . shortcode
28- : "" ;
29-
30- return gaming_shortcode
31- ? mf_shortcode_regex . test ( gaming_shortcode )
32- : false ;
33- }
34-
3522export const init = ( ) => {
3623 const banner = $ ( $banner ) . i18n ( ) ;
3724 const nav = $ ( "body" ) . find ( "nav" ) ;
@@ -43,36 +30,33 @@ export const init = () => {
4330
4431const showBanner = ( ) => {
4532 const banner = document . getElementById ( "close_banner_container" ) ;
46- if ( local_storage . get ( "oauth" ) ) {
47- liveapi . cached . authorize ( ) . then ( ( ) => {
48- const current_loginId = local_storage . get ( 'authorize' ) . loginid ;
49- const getLoginId = loginids ( ) . filter ( item => item . id === current_loginId ) ;
50- const is_mf_account = getLoginId [ 0 ] . is_mf ;
51- const is_virtual = getLoginId [ 0 ] . is_virtual ;
52- const country = local_storage . get ( "authorize" ) . country ;
53- liveapi . send ( { landing_company : country } ) . then ( ( data ) => {
54- const landing_company = data . landing_company ;
55- if ( isEuCountry ( country , landing_company ) &&
56- ( is_mf_account || ( isMFCountry ( landing_company ) && is_virtual ) ) ) {
57- banner . classList . remove ( "invisible" ) ;
58- } else {
59- banner . classList . add ( "invisible" ) ;
60- }
33+ liveapi . cached . send ( { website_status : 1 } ) . then ( ( status ) => {
34+ const ip_country = status . website_status . clients_country ;
35+ if ( local_storage . get ( "oauth" ) ) {
36+ liveapi . cached . authorize ( ) . then ( ( res ) => {
37+ const country = local_storage . get ( "authorize" ) . country ;
38+ liveapi . send ( { landing_company : country } ) . then ( ( data ) => {
39+ const landing_company = data . landing_company ;
40+ if ( ( isEuCountry ( country , landing_company ) && shouldShowBanner ( res . authorize ) )
41+ || ( loginids ( ) . length == 1 && isEuCountrySelected ( ip_country ) ) ) {
42+ banner . classList . remove ( "invisible" ) ;
43+ } else {
44+ banner . classList . add ( "invisible" ) ;
45+ }
46+ } ) ;
6147 } ) ;
62- } ) ;
63- } else {
64- liveapi . send ( { website_status : 1 } ) . then ( ( data ) => {
65- const country = data . website_status . clients_country ;
66- liveapi . send ( { landing_company : country } ) . then ( ( response ) => {
48+ } else {
49+ liveapi . send ( { landing_company : ip_country } ) . then ( ( response ) => {
6750 const landing_company = response . landing_company ;
68- if ( isEuCountry ( country , landing_company ) ) {
51+ if ( isEuCountry ( ip_country , landing_company ) ) {
6952 banner . classList . remove ( "invisible" ) ;
7053 } else {
7154 banner . classList . add ( "invisible" ) ;
7255 }
7356 } ) ;
74- } ) ;
75- }
57+ }
58+ } )
59+
7660} ;
7761
7862liveapi . events . on ( "login" , ( ) => {
@@ -87,5 +71,4 @@ liveapi.events.on("switch_account", () => {
8771
8872export default {
8973 init,
90- isEuCountry
9174} ;
0 commit comments