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

Sara / Redirect users to deriv #3482

Merged
merged 5 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,11 @@ export default class View {

if (
isLoggedin() &&
(localStorage.getItem('landingCompany') === 'maltainvest' ||
isOptionsBlocked(localStorage.getItem('residence')))
isOptionsBlocked(
localStorage.getItem('residence')
// localStorage.getItem('landingCompany') === 'maltainvest'
// this condition is commented because the MF accounts should be redirected to deriv))
)
) {
this.showHeader(getStorage('showHeader') !== 'false');
this.setElementActions();
Expand Down
71 changes: 38 additions & 33 deletions src/botPage/view/react-components/MovingBanner.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,70 @@
import React from 'react';
import { isEuCountry, isUKCountry } from '../../../common/footer-checks';
import { getTokenList, get as getStorage } from '../../../common/utils/storageManager';
import { AppConstants } from '../../../common/appId';
import { translate } from '../../../common/i18n';
import { showBanner } from '../../../common/lang';
import { isEuCountry, isUKCountry } from '../../../common/utils/utility';

/* eslint-disable camelcase */
const MovingBanner = ({ api }) => {
const [showMovingBanner, setshowMovingBanner] = React.useState(false);
const tokenList = getTokenList();

React.useEffect(() => {
checkForshowMovingBanner();
checkForshowMovingBanner().then(show => {
if (show) {
setshowMovingBanner(true);
return;
}
showBanner();
});
}, []);

const getActiveToken = activeToken => {
const activeTokenObject = tokenList.filter(tokenObject => tokenObject.token === activeToken);
return activeTokenObject.length ? activeTokenObject[0] : tokenList[0];
};

const checkForshowMovingBanner = () => {
if (!tokenList.length) {
isEuUK(api, true);
return;
}
const checkForshowMovingBanner = async () => {
const { website_status } = await api.send({ website_status: 1 });
const { clients_country } = website_status;
const residence = localStorage.getItem('residence');
const landingCompanyName = tokenList.map(token => token.loginInfo.landing_company_name);
const activeToken = getActiveToken(tokenList, getStorage(AppConstants.STORAGE_ACTIVE_TOKEN));

if (!tokenList.length) {
if (isEuCountry(clients_country) || isUKCountry(clients_country)) {
return true;
}
}
if (landingCompanyName.length === 1 && landingCompanyName.includes('virtual')) {
isEuUK(false);
return;
if (isEuCountry(residence)) {
// EU based on residence
redirectToBinary();
}
if (isEuCountry(clients_country) || isUKCountry(clients_country)) {
return true;
}
}
if (landingCompanyName.includes('maltainvest') && landingCompanyName.includes('virtual')) {
if (landingCompanyName.length === 2) {
setshowMovingBanner(true);
return;
if (landingCompanyName.includes('maltainvest')) {
if (!isEuCountry(clients_country)) {
// non EU based on ip
redirectToBinary();
}
if (
(landingCompanyName.includes('malta') || landingCompanyName.includes('iom')) &&
activeToken.loginInfo.landing_company_name === 'maltainvest'
landingCompanyName.includes('virtual') &&
(landingCompanyName.length === 2 ||
((landingCompanyName.includes('malta') || landingCompanyName.includes('iom')) &&
activeToken.loginInfo.landing_company_name === 'maltainvest'))
) {
setshowMovingBanner(true);
return;
return true;
}
}
showBanner();
return false;
};

const isEuUK = checkLoggedin => {
isEuCountry(api, checkLoggedin).then(isEu => {
if (isEu) {
setshowMovingBanner(true);
return;
}
isUKCountry(api, checkLoggedin).then(isUk => {
if (isUk) {
setshowMovingBanner(true);
return;
}
showBanner();
});
});
const redirectToBinary = () => {
window.location.replace('https://binary.com/move-to-deriv');
};

return (
Expand All @@ -68,7 +73,7 @@ const MovingBanner = ({ api }) => {
.getElementsByClassName('dbot-banner')[0]
.parentNode.removeChild(document.getElementsByClassName('dbot-banner')[0]) && (
<div className="moving-banner">
<div class="moving-banner__separator" />
<div className="moving-banner__separator" />
<img src={'image/moving-banner.svg'} />
<p className="moving-banner__text">{translate('Binary.com is moving to Deriv on 30 November')}</p>
<a className="moving-banner__button" href="http://deriv.com/">
Expand Down
19 changes: 3 additions & 16 deletions src/common/footer-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const isEuLandingCompany = landing_company => /^(maltainvest|malta|iom)$/
export const hasEuAccount = token_list =>
token_list.some(token_obj => isEuLandingCompany(token_obj.loginInfo.landing_company_name));

export const isEuCountry = async (api = generateLiveApiInstance(), checkLoggedin = true) => {
export const isEuCountry = async (api = generateLiveApiInstance()) => {
const { website_status } = await api.send({ website_status: 1 });
let { clients_country } = website_status;

if (checkLoggedin && getTokenList().length) {
// isLoggedin
// isLoggedin
if (getTokenList().length) {
clients_country = localStorage.getItem('residence');
}
const { landing_company } = await api.send({ landing_company: clients_country });
Expand All @@ -47,17 +47,4 @@ export const isEuCountry = async (api = generateLiveApiInstance(), checkLoggedin
return eu_excluded_regexp.test(clients_country);
};

export const isUKCountry = async (api = generateLiveApiInstance(), checkLoggedin = true) => {
const { website_status } = await api.send({ website_status: 1 });
let { clients_country } = website_status;
if (checkLoggedin && getTokenList().length) {
// isLoggedin
clients_country = localStorage.getItem('residence');
}
if (clients_country === 'gb') {
return true;
}
return false;
};

/* eslint-enable */
36 changes: 36 additions & 0 deletions src/common/utils/utility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const euCountries = [
'it',
'de',
'fr',
'lu',
'gr',
'mf',
'es',
'sk',
'lt',
'nl',
'at',
'bg',
'si',
'cy',
'be',
'ro',
'hr',
'pt',
'pl',
'lv',
'ee',
'cz',
'fi',
'hu',
'dk',
'se',
'ie',
'im',
'gb',
'mt',
];

export const isEuCountry = country => euCountries.includes(country);

export const isUKCountry = country => country === 'gb';
60 changes: 17 additions & 43 deletions src/indexPage/react-components/NotificationBanner.jsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,37 @@
import React from 'react';
import { translate } from '../../common/i18n';
import { isEuCountry, isUKCountry } from '../../common/footer-checks';
import { getTokenList, get as getStorage } from '../../common/utils/storageManager';
import { AppConstants } from '../../common/appId';
import { getTokenList } from '../../common/utils/storageManager';
import { isEuCountry, isUKCountry } from '../../common/utils/utility';
import { generateLiveApiInstance } from '../../common/appId';

const NotificationBanner = ({ api }) => {
const NotificationBanner = () => {
const [showBanner, setShowBanner] = React.useState(false);
const tokenList = getTokenList();

React.useEffect(() => {
checkForShowBanner();
checkForShowBanner().then(show => {
if(show){
setShowBanner(true);
}
});
}, []);

const getActiveToken = activeToken => {
const activeTokenObject = tokenList.filter(tokenObject => tokenObject.token === activeToken);
return activeTokenObject.length ? activeTokenObject[0] : tokenList[0];
};
const checkForShowBanner = async () => {
const api = generateLiveApiInstance();
const { website_status } = await api.send({ website_status: 1 });
const { clients_country } = website_status;

const checkForShowBanner = () => {
if (!tokenList.length) {
isEuUK(api, true);
return;
}
const landingCompanyName = tokenList.map(token => token.loginInfo.landing_company_name);
const activeToken = getActiveToken(tokenList, getStorage(AppConstants.STORAGE_ACTIVE_TOKEN));

if (landingCompanyName.length === 1 && landingCompanyName.includes('virtual')) {
isEuUK(false);
return;
}
if (landingCompanyName.includes('maltainvest') && landingCompanyName.includes('virtual')) {
if (landingCompanyName.length === 2) {
setShowBanner(true);
return;
}
if (
(landingCompanyName.includes('malta') || landingCompanyName.includes('iom')) &&
activeToken.loginInfo.landing_company_name === 'maltainvest'
) {
setShowBanner(true);
if(isEuCountry(clients_country) || isUKCountry (clients_country)){
return true;
}
}
};

const isEuUK = checkLoggedin => {
isEuCountry(api, checkLoggedin).then(isEu => {
if (isEu) {
setShowBanner(true);
return;
}
isUKCountry(api, checkLoggedin).then(isUk => {
setShowBanner(isUk);
});
});
return false;
};

return (
showBanner && (
<div className="notification-banner notification-banner-welcome">
<div className="notification-banner">
<img src={'image/notification-banner-icon-left.svg'} />
<div className="notification-banner__orange-hexagon"></div>
<div className="notification-banner__content">
Expand Down
40 changes: 5 additions & 35 deletions static/css/_notification-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,21 @@
flex-direction: row;
max-width: 940px;
width: 100%;
margin: auto;
align-items: center;
align-items: center;
position: absolute;
left: 50%;
transform: translate(-40%, 0);
position: relative;
margin: 1rem auto;
left: 0;
transform: none;
z-index: 100 !important;

&-welcome{
position: relative;
margin: 1rem auto;
left: 0;
transform: none;
}
&__orange-hexagon {
display: none;
border-bottom: 130px solid $brand-orange;
border-left: 0 solid transparent;
border-right: 45px solid transparent;
height: 0;
width: 26rem;

&_text {
display: flex;
flex-direction: column;
color: $white;
padding: 1rem;
}
}

&__content {
Expand All @@ -58,7 +45,6 @@
text-decoration: none;
text-align: center;
line-height: 100%;
text-transform: capitalize;
padding: 8px 25px;
display: inline-block;
font-weight: 400;
Expand All @@ -69,12 +55,7 @@
border: 0;
background: $brand-btn;
color: $white !important;
min-height: 38px;


&-welcome{
min-height: auto;
}
min-height: auto;
}

@media (max-width: 1234px) {
Expand All @@ -96,14 +77,9 @@
max-width: 880px;
}
@media (max-width: 1024px) {
max-width: 595px;
transform: translate(-35%, 0);

&-welcome{
max-width: 700px;
padding: 0 10px 0 0;
transform: none;
}

> img {
display: none;
Expand All @@ -113,14 +89,8 @@
}
}
@media (max-width: 769px) {
transform: translate(-50%, 0);
max-width: 100%;

&-welcome{
max-width: 520px;
padding: 0 10px 0 0;
transform: none;
}
}

}
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