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

Commit cd0e496

Browse files
Aizad/ Added Goto Deriv Popup for account creation (#7324)
* chore: added Goto Deriv Popup for account creation * fix: circle ci * fix: commited sugesstions * chore: show popup when clicking on create account for virtual accounts. * fix: added popup for virtual accounnt on smarttrader homepage and withdrawal section --------- Co-authored-by: Habib Deriv <88178645+habib-deriv@users.noreply.github.com>
1 parent ea0f569 commit cd0e496

File tree

5 files changed

+44
-73
lines changed

5 files changed

+44
-73
lines changed

src/javascript/app/base/header.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const createElement = require('../../_common/utility').createElement;
1919
const findParent = require('../../_common/utility').findParent;
2020
const template = require('../../_common/utility').template;
2121
const Currency = require('../common/currency');
22+
const Dialog = require('../common/attach_dom/dialog');
23+
const getLanguage = require('../../_common/language').get;
2224

2325
const Header = (() => {
2426
const onLoad = () => {
@@ -147,20 +149,21 @@ const Header = (() => {
147149
return;
148150
}
149151

150-
const showUpgrade = (url, params, localized_text) => {
152+
const showUpgrade = (localized_text) => {
151153
applyToAllElements(upgrade_msg, (el) => {
152154
el.setVisibility(1);
153155
applyToAllElements('a', (ele) => {
154-
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url, params));
156+
ele.html(createElement('span', { text: localized_text })).setVisibility(1);
157+
ele.addEventListener('click', showGoToDerivAlertPopup);
155158
}, '', el);
156159
});
157160
};
158161

159-
const showUpgradeBtn = (url, params, localized_text) => {
162+
const showUpgradeBtn = (localized_text) => {
160163
applyToAllElements(upgrade_msg, (el) => {
161164
el.setVisibility(1);
162165
applyToAllElements('a.button', (ele) => {
163-
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url, params));
166+
ele.html(createElement('span', { text: localized_text })).setVisibility(1).addEventListener('click', showGoToDerivAlertPopup);
164167
}, '', el);
165168
});
166169
};
@@ -195,11 +198,8 @@ const Header = (() => {
195198
});
196199

197200
if (show_upgrade_msg) {
198-
const upgrade_url = upgrade_info.can_upgrade_to.length > 1
199-
? 'user/accounts'
200-
: 'new_account/real_account';
201-
showUpgrade(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_link_txt);
202-
showUpgradeBtn(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_btn_txt);
201+
showUpgrade(upgrade_link_txt);
202+
showUpgradeBtn(upgrade_btn_txt);
203203
} else {
204204
applyToAllElements(upgrade_msg, (el) => {
205205
applyToAllElements('a', (ele) => {
@@ -212,11 +212,8 @@ const Header = (() => {
212212
}
213213
} else if (show_upgrade_msg) {
214214
getElementById('virtual-wrapper').setVisibility(0);
215-
const upgrade_url = upgrade_info.can_upgrade_to.length > 1
216-
? 'user/accounts'
217-
: 'new_account/real_account';
218-
showUpgrade(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_link_txt);
219-
showUpgradeBtn(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_btn_txt);
215+
showUpgrade(upgrade_link_txt);
216+
showUpgradeBtn(upgrade_btn_txt);
220217

221218
if (/new_account/.test(window.location.href)) {
222219
showHidePulser(0);
@@ -228,11 +225,25 @@ const Header = (() => {
228225
});
229226
};
230227

228+
const showGoToDerivAlertPopup = () => {
229+
const url_on_confirm = `https://app.deriv.com/?lang=${getLanguage()}`;
230+
Dialog.confirm({
231+
id : 'go-to-deriv-popup',
232+
localized_title : localize('Go to Deriv to add an account'),
233+
localized_message: localize('You\'ll be able to log in to Deriv using your Binary.com credentials.'),
234+
cancel_text : localize('Cancel'),
235+
ok_text : localize('Go to Deriv'),
236+
onConfirm : () => { window.location.href = url_on_confirm; },
237+
});
238+
};
239+
231240
const showHidePulser = (should_show) => { $('.upgrademessage').children('a').setVisibility(should_show); };
232241

233242
const showHideNewAccount = (upgrade_info) => {
234-
if (upgrade_info.can_upgrade || upgrade_info.can_open_multi) {
243+
const user_accounts = getElementById('user_accounts');
244+
if ((upgrade_info.can_upgrade || upgrade_info.can_open_multi) && user_accounts) {
235245
changeAccountsText(1, localize('Create Account'));
246+
user_accounts.addEventListener('click', () => showGoToDerivAlertPopup());
236247
} else {
237248
changeAccountsText(0, localize('Accounts List'));
238249
}
@@ -517,6 +528,7 @@ const Header = (() => {
517528
loginOnClick,
518529
switchLoginid,
519530
loginIDOnClick,
531+
showGoToDerivAlertPopup,
520532
};
521533
})();
522534

src/javascript/app/pages/cashier/cashier.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ const Cashier = (() => {
339339

340340
} else {
341341
el_paymentmethod_deposit.on('click', () => {
342-
el_paymentmethod_deposit.attr('href', Url.urlFor('/new_account/real_account'));
342+
Header.showGoToDerivAlertPopup();
343+
return false;
343344
});
344345
el_paymentmethod_withdraw.on('click', () => {
345-
el_paymentmethod_withdraw.attr('href', Url.urlFor('/new_account/real_account'));
346+
Header.showGoToDerivAlertPopup();
347+
return false;
346348
});
347349
}
348350
});

src/javascript/app/pages/user/accounts.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const SetCurrency = require('./set_currency');
33
const BinaryPjax = require('../../base/binary_pjax');
44
const Client = require('../../base/client');
55
const BinarySocket = require('../../base/socket');
6-
const AccountOpening = require('../../common/account_opening');
6+
const Header = require('../../base/header');
77
const showPopup = require('../../common/attach_dom/popup');
88
const Currency = require('../../common/currency');
99
const localize = require('../../../_common/localize').localize;
@@ -129,17 +129,12 @@ const Accounts = (() => {
129129
})))
130130
.append($('<td/>', { text: getAvailableMarkets(account), datath: table_headers.available_markets }))
131131
.append($('<td/>')
132-
.html($(
133-
'<a/>',
134-
{
135-
class: 'button',
136-
href : AccountOpening.getSinupPageLink(
137-
upgrade_info,
138-
upgrade_info.can_upgrade_to[index]
139-
),
140-
},
141-
)
142-
.html($('<span/>', { text: localize('Create account'), class: 'padding-x-30' })))));
132+
.html($('<button/>', {
133+
id : 'change_currency_btn',
134+
class: 'button no-margin',
135+
type : 'button',
136+
text : localize('Create account'),
137+
}).on('click', () => Header.showGoToDerivAlertPopup()))));
143138
});
144139
};
145140

src/javascript/app/pages/user/set_currency.js

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const moment = require('moment');
21
const setIsForNewAccount = require('./account/settings/personal_details').setIsForNewAccount;
32
const GetCurrency = require('./get_currency');
43
const BinaryPjax = require('../../base/binary_pjax');
@@ -330,32 +329,27 @@ const SetCurrency = (() => {
330329
});
331330
};
332331

333-
const onConfirm = ($currency_list, $error, should_create_account, redirect_to, all_fiat, all_crypto) => {
332+
const onConfirm = ($currency_list, $error, should_create_account, redirect_to) => {
334333
removeError($error);
335334
const $selected_currency = $currency_list.find('.selected');
336-
const has_fiat_account = Client.hasCurrencyType('fiat');
337335

338336
if ($selected_currency.length) {
339337
const selected_currency = $selected_currency.attr('id');
340338
let request = {};
341339

342340
if (popup_action === 'switch_account') {
343341
if (selected_currency === 'NEW'){
344-
localStorage.setItem('popup_action', 'multi_account');
345-
if (!all_fiat && !all_crypto && has_fiat_account) {
346-
onLoad(null, false, false, true);
347-
} else {
348-
onLoad(null, false, all_fiat, all_crypto);
349-
}
342+
cleanupPopup();
343+
Header.showGoToDerivAlertPopup();
350344
} else {
351345
cleanupPopup();
352346
Header.switchLoginid(getLoginid(selected_currency), redirect_to, true);
353347
}
354-
355348
return;
356349
}
357350
if (should_create_account) {
358-
request = populateReqMultiAccount(selected_currency);
351+
cleanupPopup();
352+
Header.showGoToDerivAlertPopup();
359353
} else {
360354
request = { set_account_currency: selected_currency };
361355
}
@@ -478,39 +472,6 @@ const SetCurrency = (() => {
478472
}
479473
};
480474

481-
const populateReqMultiAccount = (selected_currency) => {
482-
const get_settings = State.getResponse('get_settings');
483-
484-
const request = {
485-
new_account_real : 1,
486-
currency : selected_currency,
487-
date_of_birth : moment.utc(+get_settings.date_of_birth * 1000).format('YYYY-MM-DD'),
488-
salutation : get_settings.salutation,
489-
first_name : get_settings.first_name,
490-
last_name : get_settings.last_name,
491-
address_line_1 : get_settings.address_line_1,
492-
address_line_2 : get_settings.address_line_2,
493-
address_city : get_settings.address_city,
494-
address_state : get_settings.address_state,
495-
address_postcode : get_settings.address_postcode,
496-
phone : get_settings.phone,
497-
account_opening_reason: get_settings.account_opening_reason,
498-
citizen : get_settings.citizen,
499-
place_of_birth : get_settings.place_of_birth,
500-
residence : Client.get('residence'),
501-
...(get_settings.tax_identification_number && {
502-
tax_identification_number: get_settings.tax_identification_number,
503-
}),
504-
...(get_settings.tax_residence && {
505-
tax_residence: get_settings.tax_residence,
506-
}),
507-
};
508-
Object.keys(request).forEach(key => {
509-
if (!request[key] || request[key] === '') delete request[key];
510-
});
511-
return request;
512-
};
513-
514475
const cleanupPopup = () => {
515476
localStorage.removeItem('popup_action');
516477
$('.lightbox').remove();

src/sass/_common/header.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ body #topbar {
2222
color: $COLOR_WHITE;
2323
white-space: nowrap;
2424
text-decoration: none;
25+
cursor: pointer;
2526
}
2627
#select_language {
2728
top: -3px;

0 commit comments

Comments
 (0)