diff --git a/packages/api/src/hooks/useTransactions.ts b/packages/api/src/hooks/useTransactions.ts index 94a4ce33f9e9..0b4c2d47e0a0 100644 --- a/packages/api/src/hooks/useTransactions.ts +++ b/packages/api/src/hooks/useTransactions.ts @@ -32,6 +32,8 @@ const useTransactions = () => { }, payload: { action_type: filter, + // TODO: remove this once backend adds `to` and `from` for Deriv X transfers + description: 1, }, }); diff --git a/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/TransactionsCompletedRow.tsx b/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/TransactionsCompletedRow.tsx index 7557025183ca..07c573114b2c 100644 --- a/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/TransactionsCompletedRow.tsx +++ b/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/TransactionsCompletedRow.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { WalletText } from '../../../../../../components/Base'; import { THooks } from '../../../../../../types'; import { TransactionsCompletedRowAccountDetails } from './components/TransactionsCompletedRowAccountDetails'; @@ -12,6 +12,24 @@ type TProps = { }; const TransactionsCompletedRow: React.FC = ({ accounts, transaction, wallet }) => { + // TODO: remove this once backend adds `to` and `from` for Deriv X transfers + const dxtradeToFrom = useMemo(() => { + if ( + transaction?.action_type !== 'transfer' || + !transaction.longcode || + !transaction.longcode.includes('Deriv X') + ) + return null; + const longcodeMessageTokens = transaction.longcode.split(' '); + const direction = longcodeMessageTokens[1]; + const dxtradeLoginid = longcodeMessageTokens.find(token => token.startsWith('DX')); + return { + from: { loginid: wallet.loginid }, + to: { loginid: wallet.loginid }, + ...(direction && { [direction]: { loginid: dxtradeLoginid } }), + }; + }, [transaction?.action_type, transaction.longcode, wallet.loginid]); + if (!transaction.action_type || !transaction.amount) return null; const displayCurrency = wallet?.currency_config?.display_code || 'USD'; @@ -31,11 +49,12 @@ const TransactionsCompletedRow: React.FC = ({ accounts, transaction, wal ) : ( loginid !== wallet?.loginid - ) ?? '' + [ + transaction.from?.loginid ?? dxtradeToFrom?.from.loginid, + transaction.to?.loginid ?? dxtradeToFrom?.to.loginid, + ].find(loginid => loginid !== wallet?.loginid) ?? '' } /> )} diff --git a/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/components/TransactionsCompletedRowTransferAccountDetails/TransactionsCompletedRowTransferAccountDetails.tsx b/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/components/TransactionsCompletedRowTransferAccountDetails/TransactionsCompletedRowTransferAccountDetails.tsx index f6e5219323ad..cfdd1078925b 100644 --- a/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/components/TransactionsCompletedRowTransferAccountDetails/TransactionsCompletedRowTransferAccountDetails.tsx +++ b/packages/wallets/src/features/cashier/modules/Transactions/components/TransactionsCompletedRow/components/TransactionsCompletedRowTransferAccountDetails/TransactionsCompletedRowTransferAccountDetails.tsx @@ -12,7 +12,7 @@ type TProps = { const TransactionsCompletedRowTransferAccountDetails: React.FC = ({ accounts, direction, loginid }) => { const wallet = accounts.wallets?.find(account => account.loginid === loginid); const dtradeAccount = accounts.dtrade?.find(account => account.loginid === loginid); - const dxtradeAccount = accounts.dxtrade?.find(account => account.login === loginid); + const dxtradeAccount = accounts.dxtrade?.find(account => account.account_id === loginid); // TODO: remove the `replace` calls once backend resolves `statement` and `mt5_login_list` accounts `loginid` inconsistency const mt5Account = accounts.mt5?.find( account => account.login?.replace(/^\D+/g, '') === loginid.replace(/^\D+/g, '')