Skip to content

Commit

Permalink
[WALL] Lubega / WALL-3617 / Third party redirection for wallets cashi…
Browse files Browse the repository at this point in the history
…er (deriv-com#14229)

* feat: third party redirection for wallets cashier

* fix: clean up

* fix: clean up

* fix: removed feature flag dependency

* fix: changed route for transactions
  • Loading branch information
lubega-deriv authored and vinu-deriv committed May 28, 2024
1 parent 3c10503 commit 7b8238c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
52 changes: 42 additions & 10 deletions packages/core/src/App/Containers/Redirect/redirect.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withRouter, useHistory } from 'react-router-dom';
import { useStoreWalletAccountsList } from '@deriv/hooks';
import { loginUrl, routes, redirectToLogin, SessionStore, PlatformContext } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { getLanguage } from '@deriv/translations';
Expand All @@ -10,6 +11,7 @@ import { Analytics } from '@deriv-com/analytics';
const Redirect = observer(() => {
const history = useHistory();
const { client, ui } = useStore();
const { has_wallet } = useStoreWalletAccountsList();

const { currency, is_logged_in, is_logging_in, setNewEmail, setVerificationCode, verification_code } = client;

Expand All @@ -29,7 +31,6 @@ const Redirect = observer(() => {
const action_param = url_params.get('action');
const code_param = url_params.get('code') || verification_code[action_param];
const ext_platform_url = url_params.get('ext_platform_url');
const is_next_wallet = localStorage.getObject('FeatureFlagsStore')?.data?.next_wallet;
const { is_appstore } = React.useContext(PlatformContext);

const redirectToExternalPlatform = url => {
Expand Down Expand Up @@ -98,7 +99,7 @@ const Redirect = observer(() => {
if (redirect_to) {
let pathname = '';
let hash = '';
const main_screen_route = is_next_wallet ? routes.wallets : routes.traders_hub;
const main_screen_route = has_wallet ? routes.wallets : routes.traders_hub;
switch (redirect_to) {
case '1':
pathname = routes.traders_hub;
Expand Down Expand Up @@ -142,26 +143,57 @@ const Redirect = observer(() => {
setResetTradingPasswordModalOpen(true);
break;
}
case 'payment_deposit': {
if (has_wallet) {
history.push(routes.wallets_deposit);
} else {
history.push(routes.cashier_deposit);
}
redirected_to_route = true;
break;
}
case 'payment_withdraw': {
if (is_next_wallet) {
/*
if (has_wallet) {
if (verification_code?.payment_withdraw) {
/*
1. pass verification_code through query param as we do not want to use localstorage/session storage
though can't use "verification_code" as name param
as there is general logic within client-store
which removes anything which resembles code=XYZ
2. pass loginid as a query param so that the withdrawal component knows what account is being withdrawn from
*/
history.push(
`${routes.wallets_withdrawal}?verification=${verification_code.payment_withdraw}${
client.loginid ? `&loginid=${client.loginid}` : ''
}`
);
history.push(
`${routes.wallets_withdrawal}?verification=${verification_code.payment_withdraw}${
client.loginid ? `&loginid=${client.loginid}` : ''
}`
);
} else {
history.push(routes.wallets_withdrawal);
}
} else {
history.push(routes.cashier_withdrawal);
}
redirected_to_route = true;
break;
}
case 'payment_transfer': {
if (has_wallet) {
history.push(routes.wallets_transfer);
} else {
history.push(routes.cashier_acc_transfer);
}
redirected_to_route = true;
break;
}
case 'payment_transactions': {
if (has_wallet) {
history.push(routes.wallets_transactions);
} else {
history.push(routes.statement);
}
redirected_to_route = true;
break;
}
case 'payment_agent_withdraw': {
history.push(routes.cashier_pa);
redirected_to_route = true;
Expand Down Expand Up @@ -202,7 +234,7 @@ const Redirect = observer(() => {
case 'trading_platform_investor_password_reset': {
localStorage.setItem('cfd_reset_password_code', code_param);
const is_demo = localStorage.getItem('cfd_reset_password_intent')?.includes('demo');
if (is_next_wallet) {
if (has_wallet) {
history.push({
pathname: routes.wallets,
search: url_query_string,
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/src/utils/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ export const routes = {
// Wallets
wallets: '/wallets',
wallets_cashier: '/wallets/cashier',
wallets_deposit: '/wallets/cashier/deposit',
wallets_withdrawal: '/wallets/cashier/withdraw',
wallets_transfer: 'wallets/cashier/transfer',
wallets_transactions: '/wallets/cashier/transactions',
wallets_compare_accounts: '/wallets/compare-accounts',
wallets_transfer: '/wallets/cashier/transfer',

// Traders Hub
traders_hub_v2: '/traders-hub',
Expand Down

0 comments on commit 7b8238c

Please sign in to comment.