-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DTRA] Henry/wall 2135/wallets account switcher #606
[DTRA] Henry/wall 2135/wallets account switcher #606
Conversation
…n click outside and close on opening of other dropdowns like platform switcher or notification
…icons and make use of them, change account list css
…u platform switcher
@@ -28,7 +28,7 @@ const ClientBase = (() => { | |||
|
|||
const isValidLoginid = () => { | |||
if (!isLoggedIn()) return true; | |||
const valid_login_ids = new RegExp('^(MX|MF|VRTC|MLT|CR|FOG)[0-9]+$', 'i'); | |||
const valid_login_ids = new RegExp('^(MX|MF|VRTC|MLT|CR|FOG|VRW|CRW)[0-9]+$', 'i'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wallet accounts start with VRW and CRW. Without this change, page refreshes during login which causes log out.
@@ -135,6 +135,9 @@ const ClientBase = (() => { | |||
return only_real_loginids.every(loginid => get('currency', loginid) && !isCryptocurrency(get('currency', loginid))); | |||
}; | |||
|
|||
const isWalletsAccount = (loginid) => getAllAccountsObject()[loginid].account_category === 'wallet'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is not TS, it's hard to say if loginid
is defined and if it's present among keys of returned object getAllAccountsObject()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. What do u mean to say?
[loginid] accepts anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, is there opportunity to get undefined
here getAllAccountsObject()[loginid]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point. i handled the edge cases. please check
window.LC_API.on_chat_ended = () => { | ||
setNameEmail(); | ||
}; | ||
if (window.LC_API && window.LC_API.on_chat_ended) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this condition needed? - window.LC_API.on_chat_ended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is optional chaining supported here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. Theres a console error complaining because on_chat_ended doesn't exist in LC_API object. i dont believe on_chat_ended exists in the object until live chat is started then closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we are checking for this function window.LC_API.on_chat_ended
before defining it at the below line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah u r right i'll fix.
src/javascript/app/base/header.js
Outdated
@@ -92,6 +108,9 @@ const Header = (() => { | |||
applyToAllElements('.url-manage-account', el => { | |||
el.href = Url.urlForDeriv('redirect', `action=manage_account&ext_platform_url=${encodeURIComponent(window.location.href)}`); | |||
}); | |||
applyToAllElements('.url-wallets-deposit', el => { | |||
el.href = Url.urlForDeriv('wallets/cashier/transfer', `ext_platform_url=${encodeURIComponent(window.location.href)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it make sense to move encodeURIComponent(window.location.href)
in a constant and reuse it? encodeURIComponent(window.location.href)
is used in multiple lines in setHeaderUrls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya this is fine. i'll implement.
src/javascript/app/base/header.js
Outdated
el.src = Url.urlForStatic(`${header_icon_base_path}ic-bell.svg`); | ||
}); | ||
|
||
applyToAllElements('#header__notification-empty', (el) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this selectors match to that from line 111? If yes, then it should be header__notification-empty-img
Not sure, if this comment is relevant, but I noticed that all the rest selectors have a pair from constants above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i was applying to container instead of image tag. i fixed it
src/javascript/app/base/header.js
Outdated
@@ -275,7 +318,7 @@ const Header = (() => { | |||
mobile_menu__livechat_logo.src = Url.urlForStatic('images/common/livechat.svg'); | |||
|
|||
// Notification Event | |||
const notification_bell = getElementById('header__notiifcation-icon-container'); | |||
const notification_bell = getElementById('header__notifcation-icon-container'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notifcation ---> notification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch lol.
const account_switcher = Client.hasWalletsAccount() ? getElementById('wallet__switcher') : getElementById('account__switcher'); | ||
const account_switcher_dropdown = Client.hasWalletsAccount() ? getElementById('wallet__switcher-dropdown') : getElementById('account__switcher-dropdown'); | ||
const account_switcher_active = Client.hasWalletsAccount() ? 'wallet__switcher-dropdown--show' : 'account__switcher-dropdown--show'; | ||
const wallet_switcher_close = getElementById('wallet__switcher-close'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it (wallet_switcher_close
) always exist or only if Client.hasWalletsAccount() === true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because after you put an eventListener on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wallet_switcher_close
exist only if Client.hasWalletaccount() is true. I remove the whole < WalletHeader /> from the DOM at the start in switchHeader()
at the top.
Theres actually a lot of shared classnames/IDs in both <Header />
and <WalletHeader />
. Removing the switcher from the DOM was the way I could attach event handler without rewriting the same thing but with different classnames. JS didn't know where to attach the event handler when classnames/IDs are same but both headers exist in the DOM.
} else { | ||
add_account_text_eu_country.style.display = 'none'; | ||
} | ||
if (isEuCountry() && has_real_account) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, it's an old code and you didn't touch this part, but maybe:
if (isEuCountry()) {
add_account_text_normal.style.display = 'none';
if (has_real_account) {
add_account_text_eu_country.parentElement.style.display = 'none';
}
} else {
add_account_text_eu_country.style.display = 'none';
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not touch this lol. Any fart in the wind and the whole account switcher will break. It has like 4 different account types that is juggling lol
src/javascript/app/base/header.js
Outdated
const currency = Client.get('currency', loginid); | ||
const currencyName = mapCurrencyName(currency); | ||
|
||
const getIcon = (() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't get why do we need extra brackets here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a typo. thanks for pointing it out
border-top: 1px solid var(--general-hover); | ||
bottom: 0; | ||
position: fixed; | ||
width: stretch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time saw this css property for width))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didnt know until yesterday either
</div> | ||
</div> | ||
<div id='mobile_menu-content' className='mobile__menu-content mobile__menu-content--active'> | ||
<div className='mobile__platform-switcher' > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any style which can be also deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do u mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if you delete a component, which have classNames, we need to make sure that this classnames are reused or deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I can see that they are still being used in new files, sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i just removed and turned it into a component
</a> | ||
</div> | ||
<div className='wallet__header-menu-item wallet__header-menu-links client_logged_in invisible mobile-hide'> | ||
<a className='url-wallet-apps'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember exactly, but is href
attribute required? I saw a lot of places, where devs were using at least dummy href : href="#"
Please, ignore if relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in this case. hrefs are applied via javascript in header.js
. So "#" would be wrong.
@@ -135,6 +135,19 @@ const ClientBase = (() => { | |||
return only_real_loginids.every(loginid => get('currency', loginid) && !isCryptocurrency(get('currency', loginid))); | |||
}; | |||
|
|||
const isWalletsAccount = (loginid) => { | |||
if (typeof loginid === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined here is a string, is it correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
src/sass/_common/wallet_header.scss
Outdated
gap: 8px; | ||
} | ||
&-logo { | ||
width: 148px !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which style is overriding it? is it possible to move this style after the place where it gets overriden in order to avoid using !important
? or can we use some other approach to increase this CSS selector's specificity (priority) for your element without using !important? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i forget but let me check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is handled! i removed this classname completely and handled the other classname with media query
Preview Link: https://pr-606.smarttrader-preview.pages.dev
|
Changes:
Type of change