Skip to content

Commit

Permalink
Amina/trah 5318 poa redirection from high code to low code (#17985)
Browse files Browse the repository at this point in the history
* fix: add addditional dropdown options for account opening reason

* fix: redirection_of_poa

* fix: redirection_of_poa

* fix: redirection_of_poa

* fix: comment

* fix: vercel
  • Loading branch information
amina-deriv authored Jan 17, 2025
1 parent e3f78e2 commit 598e68f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/account/src/Constants/routes-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { localize } from '@deriv/translations';
import {
PersonalDetails,
ProofOfIdentityFlow,
ProofOfAddress,
ProofOfAddressFlow,
ProofOfOwnership,
Account,
DeactivateAccount,
Expand Down Expand Up @@ -160,7 +160,7 @@ const initRoutesConfig = () => [
},
{
path: routes.proof_of_address,
component: ProofOfAddress,
component: ProofOfAddressFlow,
getTitle: () => localize('Proof of address'),
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import ProofOfAddress from './proof-of-address';

export default ProofOfAddress;
export { default as ProofOfAddress } from './proof-of-address';
export { default as ProofOfAddressFlow } from './proof-of-address-flow';
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';

import { Loading } from '@deriv/components';
import { useGrowthbookGetFeatureValue } from '@deriv/hooks';
import { ACCOUNTS_OS_POA_URL, getAppId, getSocketURL } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';

import { useKycAuthStatus } from '../../../hooks';

import ProofOfAddress from './proof-of-address';

const ProofOfAddressFlow = observer(() => {
const {
client: { getToken, residence },
common: { is_from_tradershub_os },
} = useStore();
const { kyc_auth_status, isLoading: isKYCLoading } = useKycAuthStatus({ country: residence });
const [shouldRedirectToAccountsOSApp, isRedirectToAccountsOSAppFFLoaded] = useGrowthbookGetFeatureValue({
featureFlag: 'redirect_to_poa_in_accounts_os',
});

const getFormattedURL = url_link => {
const url = new URL(url_link);
const urlParams = new URLSearchParams(location.search);
const platform = urlParams.get('platform') ?? (is_from_tradershub_os ? 'tradershub_os' : 'deriv_app');

const params = {
platform,
appid: getAppId(),
lang: 'en',
server: getSocketURL(),
token: getToken(),
};

Object.entries(params).forEach(([key, value]) => {
url.searchParams.append(key, value);
});

return url.toString();
};

if (isRedirectToAccountsOSAppFFLoaded && !isKYCLoading) {
if (shouldRedirectToAccountsOSApp && kyc_auth_status) {
window.location.replace(getFormattedURL(ACCOUNTS_OS_POA_URL));
} else {
return <ProofOfAddress />;
}
}

return <Loading is_fullscreen={false} className='account__initial-loader' />;
});

export default ProofOfAddressFlow;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ProofOfIdentityFlow = observer(() => {
client: { getToken, residence },
common: { is_from_tradershub_os },
} = useStore();
const { kyc_auth_status } = useKycAuthStatus({ country: residence });
const { kyc_auth_status, isLoading: isKYCLoading } = useKycAuthStatus({ country: residence });
const [shouldRedirectToAccountsOSApp, isRedirectToAccountsOSAppFFLoaded] = useGrowthbookGetFeatureValue({
featureFlag: 'redirect_to_poi_in_accounts_os',
});
Expand All @@ -39,7 +39,7 @@ const ProofOfIdentityFlow = observer(() => {
return url.toString();
};

if (isRedirectToAccountsOSAppFFLoaded) {
if (isRedirectToAccountsOSAppFFLoaded && !isKYCLoading) {
if (shouldRedirectToAccountsOSApp && kyc_auth_status) {
const { identity } = kyc_auth_status;
const redirect_url =
Expand Down
3 changes: 2 additions & 1 deletion packages/account/src/Sections/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PersonalDetails from 'Sections/Profile/PersonalDetails';
import { ProofOfIdentityContainer, ProofOfIdentity, ProofOfIdentityFlow } from 'Sections/Verification/ProofOfIdentity';
import ProofOfAddress from 'Sections/Verification/ProofOfAddress';
import { ProofOfAddress, ProofOfAddressFlow } from 'Sections/Verification/ProofOfAddress';
import ProofOfOwnership from 'Sections/Verification/ProofOfOwnership';
import ProofOfIncome from 'Sections/Verification/ProofOfIncome';
import Account from 'Containers/Account/account';
Expand All @@ -13,6 +13,7 @@ export {
ProofOfIdentity,
ProofOfIdentityFlow,
ProofOfAddress,
ProofOfAddressFlow,
ProofOfOwnership,
ProofOfIncome,
Account,
Expand Down
5 changes: 5 additions & 0 deletions packages/shared/src/utils/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ export const ACCOUNTS_OS_POI_STATUS_URL =
process.env.NODE_ENV === 'production'
? 'https://hub.deriv.com/Accounts/ProofOfIdentityStatus'
: 'https://staging-hub.deriv.com/Accounts/ProofOfIdentityStatus';

export const ACCOUNTS_OS_POA_URL =
process.env.NODE_ENV === 'production'
? 'https://hub.deriv.com/Accounts/ProofOfAddress'
: 'https://staging-hub.deriv.com/Accounts/ProofOfAddress';

0 comments on commit 598e68f

Please sign in to comment.