From e4b2c0cbba66dac75293c5d7552f21201a71a03a Mon Sep 17 00:00:00 2001 From: nada-deriv <122768621+nada-deriv@users.noreply.github.com> Date: Tue, 30 May 2023 19:55:57 +0400 Subject: [PATCH] fix: fixed redirection back to dp2p (#7609) * fix: fixed redirection back to dp2p * fix: pr comment resolved * fix: show button for idv poi submission * fix: pr comment fix * fix: pr comment fix * fix: added destructuring default value * fix: style fix * fix: moved inline function outside * fix: style fix for redirect button in idv submit * fix: check for p2p using platform param * fix: removed unused function * fix: changed param checking from p2p to dp2p * fix: persist local storage value until cleared --- .../idv-submit-complete.tsx | 4 +-- .../proof-of-address-container.jsx | 1 + .../proof-of-identity-container.jsx | 29 +++++++++---------- packages/account/src/Styles/account.scss | 14 ++++++++- packages/core/src/Stores/common-store.js | 7 +++-- .../components/verification/verification.jsx | 10 ++++++- .../shared/src/utils/platform/platform.ts | 11 ++----- 7 files changed, 47 insertions(+), 29 deletions(-) diff --git a/packages/account/src/Components/poi/idv-status/idv-submit-complete/idv-submit-complete.tsx b/packages/account/src/Components/poi/idv-status/idv-submit-complete/idv-submit-complete.tsx index df4fc25a1a2c..0b99c7bc0ef3 100644 --- a/packages/account/src/Components/poi/idv-status/idv-submit-complete/idv-submit-complete.tsx +++ b/packages/account/src/Components/poi/idv-status/idv-submit-complete/idv-submit-complete.tsx @@ -7,7 +7,7 @@ import { localize } from '@deriv/translations'; type TIdvSubmitComplete = { needs_poa: boolean; is_from_external: boolean; - redirect_button: React.ReactNode; + redirect_button: React.ReactElement; }; const IdvSubmitComplete = ({ needs_poa, is_from_external, redirect_button }: TIdvSubmitComplete) => { @@ -30,7 +30,7 @@ const IdvSubmitComplete = ({ needs_poa, is_from_external, redirect_button }: TId {poa_button} ) : ( - redirect_button +
{redirect_button}
)} ); diff --git a/packages/account/src/Sections/Verification/ProofOfAddress/proof-of-address-container.jsx b/packages/account/src/Sections/Verification/ProofOfAddress/proof-of-address-container.jsx index e058445d07d0..0409590607f8 100644 --- a/packages/account/src/Sections/Verification/ProofOfAddress/proof-of-address-container.jsx +++ b/packages/account/src/Sections/Verification/ProofOfAddress/proof-of-address-container.jsx @@ -104,6 +104,7 @@ const ProofOfAddressContainer = ({ onClick={() => { const url = platforms[from_platform.ref]?.url; window.location.href = url; + window.localStorage.removeItem('config.platform'); }} > diff --git a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx index 435f9fbdee47..257e8b4ab2a8 100644 --- a/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx +++ b/packages/account/src/Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx @@ -1,7 +1,6 @@ import { Button, Loading } from '@deriv/components'; import { WS, getPlatformRedirect, platforms } from '@deriv/shared'; import { identity_status_codes, service_code } from './proof-of-identity-utils'; - import DemoMessage from 'Components/demo-message'; import ErrorMessage from 'Components/error-component'; import Expired from 'Components/poi/status/expired'; @@ -98,22 +97,22 @@ const ProofOfIdentityContainer = ({ return ; } - const redirect_button = should_show_redirect_btn ? ( - - ) : null; + ); if ( identity_status === identity_status_codes.none || diff --git a/packages/account/src/Styles/account.scss b/packages/account/src/Styles/account.scss index 54d5dc4f646c..303d4d0efd3b 100644 --- a/packages/account/src/Styles/account.scss +++ b/packages/account/src/Styles/account.scss @@ -2276,6 +2276,19 @@ $MIN_HEIGHT_FLOATING: calc( } } + &__redirection { + .dc-btn { + margin-top: 3.2rem; + height: 4rem; + + @include mobile { + margin: 1.6rem 0; + padding: 1.6rem; + width: 100%; + } + } + } + &__country-text { margin-bottom: 1.6rem; } @@ -2284,7 +2297,6 @@ $MIN_HEIGHT_FLOATING: calc( @include mobile { width: 94%; text-align: center; - margin-bottom: 9rem; } } diff --git a/packages/core/src/Stores/common-store.js b/packages/core/src/Stores/common-store.js index e2f60c120df7..10bcfa48710e 100644 --- a/packages/core/src/Stores/common-store.js +++ b/packages/core/src/Stores/common-store.js @@ -152,8 +152,11 @@ export default class CommonStore extends BaseStore { const search = window.location.search; if (search) { const url_params = new URLSearchParams(search); - this.platform = url_params.get('platform') || ''; - localStorage.setItem('config.platform', this.platform); + const platform = url_params.get('platform'); + if (platform) { + this.platform = platform; + localStorage.setItem('config.platform', this.platform); + } } } diff --git a/packages/p2p/src/components/verification/verification.jsx b/packages/p2p/src/components/verification/verification.jsx index e22da19d614b..b325796d0754 100644 --- a/packages/p2p/src/components/verification/verification.jsx +++ b/packages/p2p/src/components/verification/verification.jsx @@ -47,7 +47,15 @@ const Verification = ({ should_wrap }) => { general_store.poi_status === 'verified' ? () => {} : () => { - window.location.href = `${routes.proof_of_identity}?ext_platform_url=${routes.cashier_p2p}`; + const search = window.location.search; + let updated_url = `${routes.proof_of_identity}?ext_platform_url=${routes.cashier_p2p}`; + if (search) { + const url_params = new URLSearchParams(search); + const updated_url_params = new URLSearchParams(updated_url); + url_params.forEach((value, key) => updated_url_params.append(key, value)); + updated_url = `${updated_url}&${url_params.toString()}`; + } + window.location.href = updated_url; }, }, ]; diff --git a/packages/shared/src/utils/platform/platform.ts b/packages/shared/src/utils/platform/platform.ts index 0f1f2d26ca1d..64f4442d9b63 100644 --- a/packages/shared/src/utils/platform/platform.ts +++ b/packages/shared/src/utils/platform/platform.ts @@ -57,6 +57,8 @@ export const isDXtrade = () => export const isNavigationFromDerivGO = () => localStorage.getItem('config.platform') === 'derivgo'; +export const isNavigationFromP2P = () => localStorage.getItem('config.platform') === 'dp2p'; + export const getPathname = () => { const { is_pathname_bot } = isBot(); if (is_pathname_bot) return platform_name.DBot; @@ -115,8 +117,7 @@ export const getPlatformRedirect = (routing_history: TRoutingHistory) => { return { name: platform_name.DXtrade, route: routes.dxtrade }; if (isNavigationFromExternalPlatform(routing_history, routes.smarttrader)) return { name: platform_name.SmartTrader, route: routes.smarttrader }; - if (isNavigationFromP2P(routing_history, routes.cashier_p2p)) - return { name: 'P2P', route: routes.cashier_p2p, ref: 'p2p' }; + if (isNavigationFromP2P()) return { name: 'P2P', route: routes.cashier_p2p, ref: 'p2p' }; if (isNavigationFromExternalPlatform(routing_history, routes.binarybot)) return { name: platform_name.BinaryBot, route: routes.binarybot }; if (isNavigationFromDerivGO()) return { name: platform_name.DerivGO, route: '', ref: 'derivgo' }; @@ -165,12 +166,6 @@ export const isNavigationFromPlatform = ( return false; }; -export const isNavigationFromP2P = (routing_history: TRoutingHistory, platform_route: string) => { - const routing_history_index = routing_history.length > 1 ? 1 : 0; - const history_item = routing_history[routing_history_index]; - return history_item?.pathname === platform_route; -}; - export const isNavigationFromExternalPlatform = (routing_history: TRoutingHistory, platform_route: string) => { /* * Check if the client is navigating from external platform(SmartTrader or BinaryBot)