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

fix: fixed redirection back to dp2p #7609

Merged
merged 21 commits into from
May 30, 2023
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Button, Loading } from '@deriv/components';
import { getPlatformRedirect, WS } from '@deriv/shared';
import { getPlatformRedirect, platforms, WS } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import { useHistory } from 'react-router';
import DemoMessage from 'Components/demo-message';
Expand Down Expand Up @@ -97,7 +97,18 @@ const ProofOfIdentityContainer = ({
}

const redirect_button = should_show_redirect_btn && (
<Button primary className='proof-of-identity__redirect' onClick={() => routeBackTo(from_platform.route)}>
<Button
primary
className='proof-of-identity__redirect'
onClick={() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this function outside here?

if (platforms[from_platform.name?.toLowerCase()].is_hard_redirect) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if platforms[from_platform.name] is null? add a guard for that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to assign platforms[from_platform?.name] to a variable and then de-structuring is_hard_redirect and url out from it. This way you can add a guard by assigning a default value.

const platform = platforms[from_platform.name?.toLowerCase()];
const { is_hard_redirect || '', url || '' } = platform;

const url = platforms[from_platform.name?.toLowerCase()]?.url;
window.location.href = url;
} else {
routeBackTo(from_platform.route);
}
}}
>
<Localize i18n_default_text='Back to {{platform_name}}' values={{ platform_name: from_platform.name }} />
</Button>
);
Expand Down