Skip to content

Commit a94467d

Browse files
authored
Merge pull request #208 from farrah-deriv/FEQ-1305/fix-issues
farrah/fix: buy/sell and order page issues
2 parents f7e5ed2 + 9f9f885 commit a94467d

File tree

40 files changed

+121
-97
lines changed

40 files changed

+121
-97
lines changed

package-lock.json

+8-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"@babel/preset-env": "^7.24.5",
1818
"@chakra-ui/react": "^2.8.2",
1919
"@deriv-com/analytics": "^1.10.1",
20-
"@deriv-com/api-hooks": "^1.3.7",
20+
"@deriv-com/api-hooks": "^1.4.5",
2121
"@deriv-com/translations": "^1.2.4",
2222
"@deriv-com/ui": "^1.29.0",
2323
"@deriv-com/utils": "^0.0.28",
24-
"@deriv/quill-icons": "^1.22.10",
24+
"@deriv/quill-icons": "^1.23.5",
2525
"@sendbird/chat": "^4.11.3",
2626
"@svgr/rollup": "^8.1.0",
2727
"@tanstack/react-query": "^5.28.14",
@@ -108,4 +108,4 @@
108108
"vite-plugin-html-config": "^1.0.11",
109109
"vite-plugin-sass": "^0.1.0"
110110
}
111-
}
111+
}

src/assets/find-ad.svg

-1
This file was deleted.

src/assets/pay-user.svg

-1
This file was deleted.

src/assets/receive-payment.svg

-1
This file was deleted.

src/assets/received-fund.svg

-1
This file was deleted.

src/assets/release-fund.svg

-1
This file was deleted.

src/assets/scam-advance-payment.svg

-1
This file was deleted.

src/assets/scam-pot.svg

-1
This file was deleted.

src/assets/scam-sms.svg

-1
This file was deleted.

src/components/AppHeader/AccountSwitcher/AccountSwitcher.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { lazy } from 'react';
12
import { useActiveAccount } from '@/hooks/api/account';
2-
import { CurrencyUsdIcon } from '@deriv/quill-icons';
33
import { AccountSwitcher as UIAccountSwitcher } from '@deriv-com/ui';
44
import { FormatUtils } from '@deriv-com/utils';
55

@@ -8,12 +8,14 @@ type TAccountSwitcherProps = {
88
account: TActiveAccount;
99
};
1010

11+
const CurrencyIcon = lazy(() => import('../CurrencyIcon').then(module => ({ default: module.CurrencyIcon })));
12+
1113
const AccountSwitcher = ({ account }: TAccountSwitcherProps) => {
1214
const activeAccount = {
1315
balance: FormatUtils.formatMoney(account?.balance ?? 0),
1416
currency: account?.currency || 'USD',
1517
currencyLabel: account?.currency || 'US Dollar',
16-
icon: <CurrencyUsdIcon iconSize='sm' />,
18+
icon: <CurrencyIcon currency={account?.currency} isVirtual={Boolean(account?.is_virtual)} />,
1719
isActive: true,
1820
isVirtual: Boolean(account?.is_virtual),
1921
loginid: account?.loginid || '',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ReactElement, Suspense, useEffect, useState } from 'react';
2+
3+
type CurrencyIconProps = {
4+
currency: string;
5+
isVirtual: boolean;
6+
};
7+
8+
const CurrencyIcon = ({ currency, isVirtual }: CurrencyIconProps) => {
9+
const [currencyIconComponent, setCurrencyIconComponent] = useState<ReactElement | null>(null);
10+
11+
useEffect(() => {
12+
const currencyName = currency.charAt(0).toUpperCase() + currency.slice(1).toLowerCase();
13+
const currencyIconName = isVirtual ? 'CurrencyDemoIcon' : `Currency${currencyName}Icon`;
14+
const getIconComponent = async () => {
15+
const module = await import('@deriv/quill-icons');
16+
/* eslint-disable @typescript-eslint/no-explicit-any */
17+
const IconComponent = (module as any)[currencyIconName];
18+
19+
setCurrencyIconComponent(<IconComponent iconSize='sm' />);
20+
};
21+
22+
getIconComponent();
23+
}, []);
24+
25+
return <Suspense fallback={<div />}>{currencyIconComponent}</Suspense>;
26+
};
27+
28+
export default CurrencyIcon;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as CurrencyIcon } from './CurrencyIcon';

src/components/AppHeader/__tests__/AppHeader.spec.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { QueryParamProvider } from 'use-query-params';
44
import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
55
import { useActiveAccount } from '@/hooks/api/account';
66
import { useAuthData } from '@deriv-com/api-hooks';
7-
import { render, screen } from '@testing-library/react';
7+
import { render, screen, waitFor } from '@testing-library/react';
88
import userEvent from '@testing-library/user-event';
99
import AppHeader from '../AppHeader';
1010

@@ -116,6 +116,7 @@ describe('<AppHeader/>', () => {
116116
mockUseAuthData.mockReturnValue({ activeLoginid: '12345', logout: jest.fn() });
117117
mockUseActiveAccountValues.data = {
118118
currency: 'USD',
119+
is_virtual: 0,
119120
} as ReturnType<typeof useActiveAccount>['data'];
120121

121122
Object.defineProperty(window, 'matchMedia', {
@@ -139,9 +140,9 @@ describe('<AppHeader/>', () => {
139140
</QueryParamProvider>
140141
</BrowserRouter>
141142
);
142-
const logoutButton = screen.getByRole('button', { name: 'Logout' });
143+
const logoutButton = await screen.findByRole('button', { name: 'Logout' });
143144
const { logout } = mockUseAuthData();
144-
expect(logoutButton).toBeInTheDocument();
145+
await waitFor(() => expect(logoutButton).toBeInTheDocument());
145146

146147
await userEvent.click(logoutButton);
147148
expect(logout).toHaveBeenCalled();

src/components/BlockedScenarios/BlockedScenarios.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ const BlockedScenarios = ({ type }: { type: string }) => {
6161
),
6262
description: (
6363
<Text align='center'>
64-
<Localize i18n_default_text='Please switch to your USD account to access the Deriv P2P marketplace.' />
64+
<Localize i18n_default_text='To use Deriv P2P, switch to your real USD account.' />
6565
</Text>
6666
),
6767
icon: <P2pUnavailable />,
6868
title: (
6969
<Text weight='bold'>
70-
<Localize i18n_default_text='Crypto is not supported for Deriv P2P!' />
70+
<Localize i18n_default_text='Cryptocurrencies not supported' />
7171
</Text>
7272
),
7373
},

src/components/BlockedScenarios/__tests__/BlockedScenarios.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('BlockedScenarios', () => {
3333

3434
it('should render the correct message for crypto account', async () => {
3535
render(<BlockedScenarios type='crypto' />);
36-
expect(screen.getByText('Crypto is not supported for Deriv P2P!')).toBeInTheDocument();
36+
expect(screen.getByText('Cryptocurrencies not supported')).toBeInTheDocument();
3737
const button = screen.getByRole('button', { name: 'Switch to real USD account' });
3838
await userEvent.click(button);
3939
expect(window.open).toHaveBeenCalledWith('https://app.deriv.com', '_blank');

0 commit comments

Comments
 (0)