Skip to content

Commit

Permalink
Merge branch 'binary-com:master' into accounts_team/accounts_package_…
Browse files Browse the repository at this point in the history
…ts_migration/sprint_6
  • Loading branch information
utkarsha-deriv authored Nov 9, 2023
2 parents c319592 + 2be9a2e commit e4242fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jest.mock('@deriv/api', () => ({
data: {
accounts: [
{
account_type: 'wallet',
account_category: 'wallet',
balance: '100.00',
currency: 'USD',
demo_account: 0,
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('useTransferBetweenAccounts', () => {
} = renderHook(() => useTransferBetweenAccounts(), { wrapper });

expect(active_wallet).toEqual({
account_type: 'wallet',
account_category: 'wallet',
active_wallet_icon: 'IcWalletCurrencyUsd',
balance: 100,
currency: 'USD',
Expand Down
14 changes: 9 additions & 5 deletions packages/hooks/src/useTransferBetweenAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useMemo } from 'react';
import { useStore } from '@deriv/stores';
import { useFetch } from '@deriv/api';
import { useFetch, useQuery } from '@deriv/api';
import useActiveWallet from './useActiveWallet';
import useCurrencyConfig from './useCurrencyConfig';
import useExistingCFDAccounts from './useExistingCFDAccounts';
import useWalletsList from './useWalletsList';

type TAccount = NonNullable<
NonNullable<ReturnType<typeof useQuery<'transfer_between_accounts'>>['data']>['accounts']
>[number] & { account_category: 'wallet' | 'trading' };

const useTransferBetweenAccounts = () => {
const { ui } = useStore();
const { is_dark_mode_on } = ui;
Expand Down Expand Up @@ -36,7 +40,7 @@ const useTransferBetweenAccounts = () => {
return getConfig(currency || '')?.is_crypto ? 'crypto' : 'fiat';
};

const accounts = data?.accounts?.map(account => {
const accounts = (data?.accounts as TAccount[])?.map(account => {
return {
...account,
active_wallet_icon: active_wallet?.icon,
Expand All @@ -54,7 +58,7 @@ const useTransferBetweenAccounts = () => {
trading_accounts:
accounts?.reduce(
(trading_accounts, account) => {
if (account.account_type === 'wallet') return trading_accounts;
if (account.account_category === 'wallet') return trading_accounts;
if (!account.loginid) return trading_accounts;

const cfd_icon = all_linked_cfd_accounts.find(
Expand All @@ -64,7 +68,7 @@ const useTransferBetweenAccounts = () => {
trading_accounts[account.loginid] = {
...account,
gradient_class: active_wallet?.gradient_card_class,
icon: account.account_type === 'trading' ? trading_apps_icon : cfd_icon,
icon: account.account_category === 'trading' ? trading_apps_icon : cfd_icon,
...(account.account_type === 'mt5' && {
mt5_market_type: mt5_accounts?.find(
mt5_account => account.loginid && mt5_account.loginid?.includes(account.loginid)
Expand All @@ -88,7 +92,7 @@ const useTransferBetweenAccounts = () => {
wallet_accounts:
accounts?.reduce(
(wallet_accounts, wallet) => {
if (wallet.account_type !== 'wallet') return wallet_accounts;
if (wallet.account_category !== 'wallet') return wallet_accounts;
if (!wallet.loginid) return wallet_accounts;

const available_wallet = wallets?.find(acc => acc.loginid === wallet.loginid);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Step, TooltipRenderProps } from '@deriv/react-joyride';
import { TooltipRenderProps } from '@deriv/react-joyride';
import CloseIcon from '../../public/images/close-icon.svg';
import { WalletButton, WalletText } from '../Base';
import './WalletTourGuide.scss';
Expand All @@ -9,7 +9,8 @@ export const tourStepConfig = (
hasMT5Account: boolean,
hasDerivAppsTradingAccount: boolean,
isAllWalletsAlreadyAdded: boolean
): Step[] => [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any[] => [
// Wallet header
{
content: (
Expand Down

0 comments on commit e4242fa

Please sign in to comment.