Skip to content

Commit 2cab30e

Browse files
committed
fix: disable accounts
1 parent dbd75fe commit 2cab30e

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/app/App.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ function App() {
5959
};
6060
}, []);
6161

62-
// const updateAccountParamInURL = (account_data: TAuthData['account_list'][number], fallback_currency = '') => {
63-
// const search_params = new URLSearchParams(window.location.search);
64-
// const account_param = account_data.loginid.startsWith('VR')
65-
// ? 'demo'
66-
// : account_data.currency || fallback_currency;
67-
// search_params.set('account', account_param);
68-
// window.history.pushState({}, '', `${window.location.pathname}?${search_params.toString()}`);
69-
// };
62+
const updateAccountParamInURL = (account_data: TAuthData['account_list'][number], fallback_currency = '') => {
63+
const search_params = new URLSearchParams(window.location.search);
64+
const account_param = account_data.loginid.startsWith('VR')
65+
? 'demo'
66+
: account_data.currency || fallback_currency;
67+
search_params.set('account', account_param);
68+
window.history.pushState({}, '', `${window.location.pathname}?${search_params.toString()}`);
69+
};
7070

7171
React.useEffect(() => {
7272
const accounts_list = localStorage.getItem('accountsList');
@@ -85,7 +85,7 @@ function App() {
8585
);
8686
if (!selected_account) return;
8787
const [/* eslint-disable-line @typescript-eslint/no-unused-vars */ _, account] = selected_account;
88-
//updateAccountParamInURL(account);
88+
updateAccountParamInURL(account);
8989
} catch (e) {
9090
console.warn('Error', e); // eslint-disable-line no-console
9191
}
@@ -142,7 +142,7 @@ function App() {
142142
);
143143
if (!selected_account) return;
144144
const [_, account] = selected_account; // eslint-disable-line @typescript-eslint/no-unused-vars
145-
//updateAccountParamInURL(account, 'USD');
145+
updateAccountParamInURL(account, 'USD');
146146
}
147147
} catch (e) {
148148
console.warn('Error', e); // eslint-disable-line no-console

src/components/layout/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,18 @@ const Layout = () => {
5656
if (hasMissingCurrency) {
5757
setClientHasCurrency(false);
5858
} else {
59+
const enabled_account_currency = enabled_accounts
60+
?.filter(acc => acc.currency === currency)
61+
.map(acc => acc.currency);
62+
63+
window.history.pushState(
64+
{},
65+
'',
66+
`${window.location.pathname}?${(sessionStorage.getItem('query_param_currency') || `account=${enabled_account_currency}`).toString()}`
67+
);
5968
sessionStorage.removeItem('query_param_currency');
6069
setClientHasCurrency(true);
70+
console.log('all accounts present');
6171
}
6272

6373
if (subscription) {

0 commit comments

Comments
 (0)