|
1 | 1 | /* eslint-disable import/prefer-default-export */ |
2 | 2 | import { generateLiveApiInstance } from './appId'; |
3 | 3 |
|
4 | | -export default async function isEuCountry() { |
5 | | - const api = generateLiveApiInstance(); |
6 | | - const { website_status: { clients_country: clientsCountry } } = await api.send({ website_status: 1 }); |
7 | | - const { landing_company: { financial_company: financialCompany, gaming_company: gamingCompany } } = await api.send({ |
8 | | - landing_company: clientsCountry, |
| 4 | +export const showHideEuElements = isEu => { |
| 5 | + document.querySelectorAll('.eu-hide').forEach(el => { |
| 6 | + if (!isEu && el.classList.contains('invisible')) { |
| 7 | + // Keep original display type if invisible was specified. |
| 8 | + el.classList.remove('invisible'); |
| 9 | + } else { |
| 10 | + // Default to setting display to block. |
| 11 | + el.setAttribute('display', `${!isEu ? 'block' : 'none'} !important`); |
| 12 | + } |
9 | 13 | }); |
| 14 | + document.querySelectorAll('.eu-show', '.eu-only').forEach(el => { |
| 15 | + if (isEu && el.classList.contains('invisible')) { |
| 16 | + el.classList.remove('invisible'); |
| 17 | + } else { |
| 18 | + el.setAttribute('display', `${isEu ? 'block' : 'none'} !important`); |
| 19 | + } |
| 20 | + }); |
| 21 | +}; |
| 22 | + |
| 23 | +/* eslint-disable camelcase */ |
| 24 | +export const isEuLandingCompany = landing_company => /^(maltainvest|malta|iom)$/.test(landing_company); |
| 25 | + |
| 26 | +export const hasEuAccount = token_list => |
| 27 | + token_list.some(token_obj => isEuLandingCompany(token_obj.loginInfo.landing_company_name)); |
| 28 | + |
| 29 | +export const isEuCountry = async (api = generateLiveApiInstance()) => { |
| 30 | + const { website_status } = await api.send({ website_status: 1 }); |
| 31 | + const { clients_country } = website_status; |
| 32 | + const { landing_company } = await api.send({ landing_company: clients_country }); |
| 33 | + const { financial_company, gaming_company } = landing_company; |
10 | 34 |
|
11 | | - const euShortcodeRegex = new RegExp('^(maltainvest|malta|iom)$'); |
12 | | - const euExcludedRegex = new RegExp('^mt$'); |
13 | | - const financialShortcode = financialCompany ? financialCompany.shortcode : false; |
14 | | - const gamingShortcode = gamingCompany ? gamingCompany.shortcode : false; |
| 35 | + const eu_excluded_regexp = /^mt$/; |
| 36 | + const financial_shortcode = financial_company ? financial_company.shortcode : false; |
| 37 | + const gaming_shortcode = gaming_company ? gaming_company.shortcode : false; |
15 | 38 |
|
16 | | - api.disconnect(); |
| 39 | + if (financial_shortcode || gaming_shortcode) { |
| 40 | + return isEuLandingCompany(financial_shortcode) || isEuLandingCompany(gaming_shortcode); |
| 41 | + } |
17 | 42 |
|
18 | | - return financialShortcode || gamingShortcode |
19 | | - ? euShortcodeRegex.test(financialShortcode) || euShortcodeRegex.test(gamingShortcode) |
20 | | - : euExcludedRegex.test(clientsCountry); |
21 | | -} |
| 43 | + return eu_excluded_regexp.test(clients_country); |
| 44 | +}; |
| 45 | +/* eslint-enable */ |
0 commit comments