Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrienne / Store redirect metadata for traders hub from os-redirect #18021

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -35,8 +35,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 && !!trading_hub && !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
Loading