Skip to content

Commit

Permalink
fix: disable accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
rupato-deriv committed Mar 6, 2025
1 parent dbd75fe commit 2cab30e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ function App() {
};
}, []);

// const updateAccountParamInURL = (account_data: TAuthData['account_list'][number], fallback_currency = '') => {
// const search_params = new URLSearchParams(window.location.search);
// const account_param = account_data.loginid.startsWith('VR')
// ? 'demo'
// : account_data.currency || fallback_currency;
// search_params.set('account', account_param);
// window.history.pushState({}, '', `${window.location.pathname}?${search_params.toString()}`);
// };
const updateAccountParamInURL = (account_data: TAuthData['account_list'][number], fallback_currency = '') => {
const search_params = new URLSearchParams(window.location.search);
const account_param = account_data.loginid.startsWith('VR')
? 'demo'
: account_data.currency || fallback_currency;
search_params.set('account', account_param);
window.history.pushState({}, '', `${window.location.pathname}?${search_params.toString()}`);
};

React.useEffect(() => {
const accounts_list = localStorage.getItem('accountsList');
Expand All @@ -85,7 +85,7 @@ function App() {
);
if (!selected_account) return;
const [/* eslint-disable-line @typescript-eslint/no-unused-vars */ _, account] = selected_account;
//updateAccountParamInURL(account);
updateAccountParamInURL(account);
} catch (e) {
console.warn('Error', e); // eslint-disable-line no-console
}
Expand Down Expand Up @@ -142,7 +142,7 @@ function App() {
);
if (!selected_account) return;
const [_, account] = selected_account; // eslint-disable-line @typescript-eslint/no-unused-vars
//updateAccountParamInURL(account, 'USD');
updateAccountParamInURL(account, 'USD');
}
} catch (e) {
console.warn('Error', e); // eslint-disable-line no-console
Expand Down
10 changes: 10 additions & 0 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ const Layout = () => {
if (hasMissingCurrency) {
setClientHasCurrency(false);
} else {
const enabled_account_currency = enabled_accounts
?.filter(acc => acc.currency === currency)
.map(acc => acc.currency);

window.history.pushState(
{},
'',
`${window.location.pathname}?${(sessionStorage.getItem('query_param_currency') || `account=${enabled_account_currency}`).toString()}`
);
sessionStorage.removeItem('query_param_currency');
setClientHasCurrency(true);
console.log('all accounts present');
}

if (subscription) {
Expand Down

0 comments on commit 2cab30e

Please sign in to comment.