Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 58010b9

Browse files
committed
Update logo + EU detection for (non-)logged in users
1 parent 81b87d6 commit 58010b9

File tree

6 files changed

+41
-38
lines changed

6 files changed

+41
-38
lines changed

src/botPage/common/const.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ const config = {
235235
quick_strategies: ['martingale', 'dalembert'],
236236
};
237237

238-
export async function updateConfigCurrencies() {
239-
const api = generateLiveApiInstance();
238+
export async function updateConfigCurrencies(api = generateLiveApiInstance()) {
240239
try {
241240
const response = await api.getPayoutCurrencies();
242241
config.lists.CURRENCY = response.payout_currencies.map(c => [c, c]);

src/botPage/view/View.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
addTokenIfValid,
2929
} from '../../common/appId';
3030
import { translate } from '../../common/i18n';
31-
import isEuCountry, { showHideEuElements } from '../../common/footer-checks';
31+
import { isEuCountry, showHideEuElements, hasEuAccount } from '../../common/footer-checks';
3232
import googleDrive from '../../common/integrations/GoogleDrive';
3333
import { getLanguage } from '../../common/lang';
3434
import { observer as globalObserver } from '../../common/utils/observer';
@@ -187,6 +187,9 @@ const updateTokenList = () => {
187187
loginButton.show();
188188
accountList.hide();
189189

190+
// If logged out, determine EU based on IP.
191+
isEuCountry(api).then(isEu => showHideEuElements(isEu));
192+
190193
$('.account-id')
191194
.removeAttr('value')
192195
.text('');
@@ -197,13 +200,17 @@ const updateTokenList = () => {
197200
} else {
198201
loginButton.hide();
199202
accountList.show();
203+
200204
const activeToken = getActiveToken(tokenList, getStorage(AppConstants.STORAGE_ACTIVE_TOKEN));
205+
showHideEuElements(hasEuAccount(tokenList));
201206
updateLogo(activeToken.token);
202207
addBalanceForToken(activeToken.token);
208+
203209
if (!('loginInfo' in activeToken)) {
204210
removeAllTokens();
205211
updateTokenList();
206212
}
213+
207214
tokenList.forEach(tokenInfo => {
208215
const prefix = isVirtual(tokenInfo) ? 'Virtual Account' : `${tokenInfo.loginInfo.currency} Account`;
209216
if (tokenInfo === activeToken) {
@@ -234,7 +241,7 @@ export default class View {
234241
constructor() {
235242
logHandler();
236243
this.initPromise = new Promise(resolve => {
237-
updateConfigCurrencies().then(() => {
244+
updateConfigCurrencies(api).then(() => {
238245
symbolPromise.then(() => {
239246
updateTokenList();
240247
this.blockly = new _Blockly();
@@ -727,7 +734,6 @@ function initRealityCheck(stopCallback) {
727734
);
728735
}
729736
function renderReactComponents() {
730-
isEuCountry().then(isEu => showHideEuElements(isEu));
731737
ReactDOM.render(<ServerTime api={api} />, $('#server-time')[0]);
732738
ReactDOM.render(<Tour />, $('#tour')[0]);
733739
ReactDOM.render(

src/common/footer-checks.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@ export const showHideEuElements = isEu => {
2020
});
2121
};
2222

23-
export default async function isEuCountry() {
24-
const api = generateLiveApiInstance();
25-
const {
26-
website_status: { clients_country: clientsCountry },
27-
} = await api.send({ website_status: 1 });
28-
const {
29-
landing_company: { financial_company: financialCompany, gaming_company: gamingCompany },
30-
} = await api.send({
31-
landing_company: clientsCountry,
32-
});
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));
3328

34-
const euShortcodeRegex = new RegExp('^(maltainvest|malta|iom)$');
35-
const euExcludedRegex = new RegExp('^mt$');
36-
const financialShortcode = financialCompany ? financialCompany.shortcode : false;
37-
const gamingShortcode = gamingCompany ? gamingCompany.shortcode : false;
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;
3834

39-
api.disconnect();
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;
4038

41-
return financialShortcode || gamingShortcode
42-
? euShortcodeRegex.test(financialShortcode) || euShortcodeRegex.test(gamingShortcode)
43-
: euExcludedRegex.test(clientsCountry);
44-
}
39+
if (financial_shortcode || gaming_shortcode) {
40+
return isEuLandingCompany(financial_shortcode) || isEuLandingCompany(gaming_shortcode);
41+
}
42+
43+
return eu_excluded_regexp.test(clients_country);
44+
};
45+
/* eslint-enable */

src/indexPage/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ import endpoint from './endpoint';
44
import Logo from './react-components/logo.jsx';
55
import Footer from './react-components/footer.jsx';
66
import { oauthLogin } from '../common/appId';
7-
import '../common/binary-ui/dropdown';
8-
import isEuCountry, { showHideEuElements } from '../common/footer-checks';
7+
import { isEuCountry, showHideEuElements } from '../common/footer-checks';
98
import GTM from '../common/gtm';
109
import { load as loadLang } from '../common/lang';
1110
import { getTokenList } from '../common/utils/storageManager';
1211
import { createUrl } from '../common/utils/tools';
12+
import '../common/binary-ui/dropdown';
1313

1414
const renderElements = () => {
1515
ReactDOM.render(<Logo />, document.getElementById('binary-logo'));
1616
ReactDOM.render(<Footer />, document.getElementById('footer'));
17-
isEuCountry().then(isEu => {
18-
showHideEuElements(isEu);
19-
});
17+
isEuCountry().then(isEu => showHideEuElements(isEu));
2018
$('#shop-url').attr('href', createUrl({ subdomain: 'shop', path: 'collections/strategies', isNonBotPage: true }));
2119
};
2220

static/css/_dbot-banner.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.dbot-banner {
2+
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@700&display=swap');
3+
font-family: 'IBM Plex Sans', sans-serif;
24
-webkit-font-smoothing: antialiased;
35
-moz-osx-font-smoothing: antialiased;
46
align-items: center;
@@ -14,17 +16,14 @@
1416
}
1517
&__ad {
1618
color: #fff;
17-
margin-right: 11px;
19+
margin-right: 16px;
1820
display: flex;
1921
justify-content: center;
2022

21-
&-title {
22-
font-weight: normal;
23-
font-size: 14px;
24-
}
25-
&-subtitle {
23+
&-text {
2624
font-size: 16px;
2725
font-weight: bold;
26+
line-height: 1.5;
2827
}
2928
}
3029
&__button {
@@ -37,7 +36,7 @@
3736
touch-action: manipulation;
3837
cursor: pointer;
3938
white-space: nowrap;
40-
padding: 0 1.6rem;
39+
padding: 0 16px;
4140
display: inline-flex;
4241
border: 0;
4342
height: 32px;

templates/partials/dbot-banner.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</a>
99
<div class="dbot-banner__ad">
1010
<a href="https://deriv.com/interim/deriv/?utm_source=binary-bot&utm_medium=referral&utm_campaign=deriv-launch" target="_blank">
11-
<div class="dbot-banner__ad-title" data-i18n-text="Experience our"></div>
12-
<div class="dbot-banner__ad-subtitle" data-i18n-text="new bot builder on Deriv"></div>
11+
<div class="dbot-banner__ad-text" data-i18n-text="Binary Bot is"></div>
12+
<div class="dbot-banner__ad-text" data-i18n-text="becoming DBot"></div>
1313
</a>
1414
</div>
1515
<a class="dbot-banner__button" href="https://deriv.com/interim/deriv/?utm_source=binary-bot&utm_medium=referral&utm_campaign=deriv-launch" target="_blank" data-i18n-text="Learn more"></a>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy