From 2cab30e589ae74cd826f5b1e9ff236b3cb4076b2 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Thu, 6 Mar 2025 10:49:02 +0800 Subject: [PATCH] fix: disable accounts --- src/app/App.tsx | 20 ++++++++++---------- src/components/layout/index.tsx | 10 ++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index f7d798a0..1921b322 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -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'); @@ -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 } @@ -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 diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx index ba751bb6..dfbc1b84 100644 --- a/src/components/layout/index.tsx +++ b/src/components/layout/index.tsx @@ -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) {