diff --git a/packages/cashier/src/containers/routes/binary-routes.tsx b/packages/cashier/src/containers/routes/binary-routes.tsx index 02c1f6c478cb..4267665cfdd1 100644 --- a/packages/cashier/src/containers/routes/binary-routes.tsx +++ b/packages/cashier/src/containers/routes/binary-routes.tsx @@ -3,7 +3,7 @@ import { Switch } from 'react-router-dom'; import { Loading } from '@deriv/components'; import { useIsHubRedirectionEnabled } from '@deriv/hooks'; -import { deriv_urls, getDomainUrl } from '@deriv/shared'; +import { getDomainUrl } from '@deriv/shared'; import { useStore } from '@deriv/stores'; import getRoutesConfig from 'Constants/routes-config'; @@ -32,9 +32,14 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { const STAGING_REDIRECT_URL = `https://staging-hub.${getDomainUrl()}/tradershub`; useEffect(() => { + if (has_wallet === undefined) { + // eslint-disable-next-line no-console + console.error('Unable to retrieve wallet information from API.'); + } + if ( isHubRedirectionEnabled && - has_wallet && + has_wallet && !is_logging_out && is_logged_in && !prevent_redirect_to_hub && @@ -42,15 +47,10 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { ) { const redirectUrl = process.env.NODE_ENV === 'production' ? PRODUCTION_REDIRECT_URL : STAGING_REDIRECT_URL; - const domain = /deriv\.(com|me|be)/.test(window.location.hostname) - ? deriv_urls.DERIV_HOST_NAME - : window.location.hostname; - Cookies.set('wallet_account', true, { domain }); - const url_query_string = window.location.search; const url_params = new URLSearchParams(url_query_string); const account_currency = window.sessionStorage.getItem('account') || url_params.get('account'); - localStorage.setItem('wallet_redirect_done', true); + localStorage.setItem('wallet_redirect_done', 'true'); const redirect_path = `${redirectUrl}/redirect?action=redirect_to&redirect_to=wallet${account_currency ? `&account=${account_currency}` : ''}`; window.location.href = redirect_path; } @@ -59,6 +59,7 @@ const BinaryRoutes = (props: TBinaryRoutesProps) => { if (prevent_single_login && isHubRedirectionLoaded && is_client_store_initialized && shouldStayInDerivApp) { setPreventSingleLogin(false); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ isHubRedirectionLoaded, isHubRedirectionEnabled,