Skip to content

Commit

Permalink
Adrienne / Store redirect metadata for traders hub from os-redirect (#…
Browse files Browse the repository at this point in the history
…18021)

* feat: store redirect metadata for traders hub from os-redirect

* chore: change redirect url for traders hub as requested
  • Loading branch information
adrienne-deriv authored Jan 24, 2025
1 parent c627c5e commit 99fe70a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/App/Containers/OSRedirect/os-redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const OSRedirect = () => {
];
const route = routes_list.find(({ pattern }) => pattern.test(url_query_string));
route?.type && params.set('trade_type', route.type);

if (route) {
sessionStorage.setItem('tradershub_redirect_to', `${route?.route}?${params.toString()}`);
}
/**
* Redirect to route if user is logged in
* Need to wait logged in state to be updated before redirecting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const RootComponent = observer(props => {
};
const { isHubRedirectionEnabled } = useIsHubRedirectionEnabled();

const PRODUCTION_REDIRECT_URL = 'https://hub.deriv.com/tradershub/options';
const STAGING_REDIRECT_URL = 'https://staging-hub.deriv.com/tradershub/options';
const PRODUCTION_REDIRECT_URL = 'https://hub.deriv.com/tradershub/cfds';
const STAGING_REDIRECT_URL = 'https://staging-hub.deriv.com/tradershub/cfds';

useEffect(() => {
if (isHubRedirectionEnabled && has_wallet && !prevent_redirect_to_hub) {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/Modules/Callback/CallbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ const CallbackPage = () => {
localStorage.setItem('config.account1', tokens.token1);
localStorage.setItem('active_loginid', tokens.acct1);

window.location.href = routes.traders_hub;
const redirectTo = sessionStorage.getItem('tradershub_redirect_to');
if (redirectTo) {
window.location.href = redirectTo;
} else {
window.location.href = routes.traders_hub;
}
}}
renderReturnButton={() => {
return (
Expand Down

0 comments on commit 99fe70a

Please sign in to comment.