Skip to content

Commit

Permalink
chore: resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienne-deriv committed Jul 30, 2024
2 parents 5c17892 + a94467d commit d8d8252
Show file tree
Hide file tree
Showing 40 changed files with 121 additions and 97 deletions.
21 changes: 8 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"@babel/preset-env": "^7.24.5",
"@chakra-ui/react": "^2.8.2",
"@deriv-com/analytics": "^1.10.1",
"@deriv-com/api-hooks": "^1.3.7",
"@deriv-com/api-hooks": "^1.4.5",
"@deriv-com/translations": "^1.2.4",
"@deriv-com/ui": "^1.29.0",
"@deriv-com/utils": "^0.0.28",
"@deriv/quill-icons": "^1.22.10",
"@deriv/quill-icons": "^1.23.5",
"@sendbird/chat": "^4.11.3",
"@svgr/rollup": "^8.1.0",
"@tanstack/react-query": "^5.28.14",
Expand Down Expand Up @@ -111,4 +111,4 @@
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.9.5"
}
}
}
1 change: 0 additions & 1 deletion src/assets/find-ad.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/pay-user.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/receive-payment.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/received-fund.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/release-fund.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/scam-advance-payment.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/scam-pot.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/scam-sms.svg

This file was deleted.

6 changes: 4 additions & 2 deletions src/components/AppHeader/AccountSwitcher/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lazy } from 'react';
import { useActiveAccount } from '@/hooks/api/account';
import { CurrencyUsdIcon } from '@deriv/quill-icons';
import { AccountSwitcher as UIAccountSwitcher } from '@deriv-com/ui';
import { FormatUtils } from '@deriv-com/utils';

Expand All @@ -8,12 +8,14 @@ type TAccountSwitcherProps = {
account: TActiveAccount;
};

const CurrencyIcon = lazy(() => import('../CurrencyIcon').then(module => ({ default: module.CurrencyIcon })));

const AccountSwitcher = ({ account }: TAccountSwitcherProps) => {
const activeAccount = {
balance: FormatUtils.formatMoney(account?.balance ?? 0),
currency: account?.currency || 'USD',
currencyLabel: account?.currency || 'US Dollar',
icon: <CurrencyUsdIcon iconSize='sm' />,
icon: <CurrencyIcon currency={account?.currency} isVirtual={Boolean(account?.is_virtual)} />,
isActive: true,
isVirtual: Boolean(account?.is_virtual),
loginid: account?.loginid || '',
Expand Down
28 changes: 28 additions & 0 deletions src/components/AppHeader/CurrencyIcon/CurrencyIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ReactElement, Suspense, useEffect, useState } from 'react';

type CurrencyIconProps = {
currency: string;
isVirtual: boolean;
};

const CurrencyIcon = ({ currency, isVirtual }: CurrencyIconProps) => {
const [currencyIconComponent, setCurrencyIconComponent] = useState<ReactElement | null>(null);

useEffect(() => {
const currencyName = currency.charAt(0).toUpperCase() + currency.slice(1).toLowerCase();
const currencyIconName = isVirtual ? 'CurrencyDemoIcon' : `Currency${currencyName}Icon`;
const getIconComponent = async () => {
const module = await import('@deriv/quill-icons');
/* eslint-disable @typescript-eslint/no-explicit-any */
const IconComponent = (module as any)[currencyIconName];

setCurrencyIconComponent(<IconComponent iconSize='sm' />);
};

getIconComponent();
}, []);

Check warning on line 23 in src/components/AppHeader/CurrencyIcon/CurrencyIcon.tsx

View workflow job for this annotation

GitHub Actions / build_to_cloudflare_pages

React Hook useEffect has missing dependencies: 'currency' and 'isVirtual'. Either include them or remove the dependency array

return <Suspense fallback={<div />}>{currencyIconComponent}</Suspense>;
};

export default CurrencyIcon;
1 change: 1 addition & 0 deletions src/components/AppHeader/CurrencyIcon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as CurrencyIcon } from './CurrencyIcon';
7 changes: 4 additions & 3 deletions src/components/AppHeader/__tests__/AppHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QueryParamProvider } from 'use-query-params';
import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { useActiveAccount } from '@/hooks/api/account';
import { useAuthData } from '@deriv-com/api-hooks';
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import AppHeader from '../AppHeader';

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

Object.defineProperty(window, 'matchMedia', {
Expand All @@ -139,9 +140,9 @@ describe('<AppHeader/>', () => {
</QueryParamProvider>
</BrowserRouter>
);
const logoutButton = screen.getByRole('button', { name: 'Logout' });
const logoutButton = await screen.findByRole('button', { name: 'Logout' });
const { logout } = mockUseAuthData();
expect(logoutButton).toBeInTheDocument();
await waitFor(() => expect(logoutButton).toBeInTheDocument());

await userEvent.click(logoutButton);
expect(logout).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions src/components/BlockedScenarios/BlockedScenarios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ const BlockedScenarios = ({ type }: { type: string }) => {
),
description: (
<Text align='center'>
<Localize i18n_default_text='Please switch to your USD account to access the Deriv P2P marketplace.' />
<Localize i18n_default_text='To use Deriv P2P, switch to your real USD account.' />
</Text>
),
icon: <P2pUnavailable />,
title: (
<Text weight='bold'>
<Localize i18n_default_text='Crypto is not supported for Deriv P2P!' />
<Localize i18n_default_text='Cryptocurrencies not supported' />
</Text>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('BlockedScenarios', () => {

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

0 comments on commit d8d8252

Please sign in to comment.