From 602ab8029ad914272efbfb16bbbee31b846ce423 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Tue, 18 Feb 2025 17:23:34 +0800 Subject: [PATCH] fix: added isclient check --- src/components/layout/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx index 9f5d8d1b..3313b971 100644 --- a/src/components/layout/index.tsx +++ b/src/components/layout/index.tsx @@ -21,6 +21,9 @@ const Layout = () => { const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}'); const getQueryParams = new URLSearchParams(window.location.search); const currency = getQueryParams.get('account') ?? ''; + const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}'); + const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0; + const ifClientAccountHasCurrency = Object.values(checkClientAccount).some(account => account.currency === currency) || currency === 'demo'; @@ -31,13 +34,12 @@ const Layout = () => { }); useEffect(() => { - if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) { - console.log('requestOidcAuthentication'); + if (isLoggedInCookie && !isClientAccountsPopulated && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) { requestOidcAuthentication({ redirectCallbackUri: `${window.location.origin}/callback`, }); } - }, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]); + }, [isLoggedInCookie, isClientAccountsPopulated, isOAuth2Enabled, isEndpointPage, isCallbackPage]); return (