1
1
const Client = require ( './client' ) ;
2
+ const BinarySocket = require ( './socket' ) ;
2
3
const getElementById = require ( '../../_common/common_functions' ) . getElementById ;
3
4
const applyToAllElements = require ( '../../_common/utility' ) . applyToAllElements ;
4
5
const findParent = require ( '../../_common/utility' ) . findParent ;
5
- const State = require ( '../../_common/storage ' ) . State ;
6
+ const getPropertyValue = require ( '../../_common/utility ' ) . getPropertyValue ;
6
7
require ( '../../_common/lib/mmenu/jquery.mmenu.min.all.js' ) ;
7
8
8
9
const Menu = ( ( ) => {
@@ -11,9 +12,14 @@ const Menu = (() => {
11
12
12
13
applyToAllElements ( 'li' , ( el ) => { el . classList . remove ( 'active' , 'active-parent' ) ; } , '' , menu_top ) ;
13
14
if ( Client . isLoggedIn ( ) ) {
14
- applyToAllElements ( '.cr-only' , ( el ) => {
15
- const is_upgradable_to_cr = State . getResponse ( 'authorize.upgradeable_landing_companies' ) . indexOf ( 'costarica' ) !== - 1 ;
16
- el . setVisibility ( Client . hasCostaricaAccount ( ) || is_upgradable_to_cr ) ;
15
+ BinarySocket . wait ( 'landing_company' ) . then ( ( response ) => {
16
+ const financial_shortcode = getPropertyValue ( response , [ 'landing_company' , 'financial_company' , 'shortcode' ] ) ;
17
+ // client is virtual and they are allowed to have a financial account
18
+ // or client is real and current account is financial
19
+ const has_financial_markets = Client . get ( 'is_virtual' ) ? ! ! ( financial_shortcode ) : Client . get ( 'landing_company_shortcode' ) === financial_shortcode ;
20
+ applyToAllElements ( '.financial-only' , ( el ) => {
21
+ el . setVisibility ( has_financial_markets ) ;
22
+ } ) ;
17
23
} ) ;
18
24
}
19
25
0 commit comments