diff --git a/src/components/layout/header/account-switcher.tsx b/src/components/layout/header/account-switcher.tsx index 4dbe5b4f..33223250 100644 --- a/src/components/layout/header/account-switcher.tsx +++ b/src/components/layout/header/account-switcher.tsx @@ -39,14 +39,31 @@ const tabs_labels = { real: localize('Real'), }; +interface AccountSwitcherData { + renderCountryIsLowRiskAndHasNoRealAccount: boolean; + renderCountryIsEuAndNoRealAccount: boolean; + renderCountryIsNonEuAndNoRealAccount: boolean; + renderCountryIsEuHasOnlyRealAccount: boolean; + renderCountryIsNonEuHasOnlyRealAccount: boolean; + renderCountryIsLowRiskAndHasRealAccount: boolean; +} + const RenderAccountItems = ({ isVirtual, modifiedAccountList, switchAccount }: TAccountSwitcherProps) => { const { client } = useStore(); - const account_data = useRef(); + const { landing_companies } = client; + + const account_switcher_data = useRef(null); const fetchAccountSwitcherData = useCallback(async () => { - if (account_data.current || !client?.loginid || !modifiedAccountList) return; - const account_info = await checkSwitcherType(modifiedAccountList, client.loginid, isVirtual); - if (account_data) account_data.current = account_info; + if (account_switcher_data.current || !client?.loginid || !modifiedAccountList) return; + const account_data = { + login_id: client.loginid, + modifiedAccountList, + landing_companies, + is_virtual: isVirtual, + }; + const account_info = await checkSwitcherType(account_data); + account_switcher_data.current = account_info; }, [client, modifiedAccountList]); useEffect(() => { diff --git a/src/components/layout/header/utils/index.js b/src/components/layout/header/utils/index.js index 7832d9d9..86933e68 100644 --- a/src/components/layout/header/utils/index.js +++ b/src/components/layout/header/utils/index.js @@ -70,7 +70,9 @@ const isMultiplier = landing_company_list => { }; }; -export const checkSwitcherType = async (client_accounts = {}, activeLoginid, isVirtual) => { +export const checkSwitcherType = async account_data => { + const { client_accounts = {}, activeLoginid, isVirtual, landing_company } = account_data; + const virtual_accounts = []; const non_eu_accounts = []; const eu_accounts = []; @@ -79,7 +81,6 @@ export const checkSwitcherType = async (client_accounts = {}, activeLoginid, isV const account_info = { ...api_base.account_info }; if (!account_info) return null; - const landing_company = await api_base.getLandingCompany(); const account_status = { ...api_base.account_status }; @@ -87,7 +88,8 @@ export const checkSwitcherType = async (client_accounts = {}, activeLoginid, isV const is_eu = isEu(country); const { country_code } = isMultiplier(landing_company); //TODO: check if this is needed - // const { is_multiplier } = isMultiplier(landing_company); + //is_multiplier + // const is_high_risk_or_eu = is_eu && is_high_risk; const { financial_company, gaming_company } = landing_company;