Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into shayan/…
Browse files Browse the repository at this point in the history
…52349/react17-migration
  • Loading branch information
iman committed Jan 2, 2023
2 parents b90729d + c743761 commit de81fd4
Show file tree
Hide file tree
Showing 71 changed files with 1,306 additions and 1,155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ const AccountLimits = ({

const { commodities, forex, indices, synthetic_index } = { ...market_specific };
const forex_ordered = forex?.slice().sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0));
const derived_ordered = synthetic_index?.slice().sort((b, a) => (a.level < b.level ? 1 : -1));
// sort submarkets by names alphabetically and put 'market' at the beginning
const derived_ordered = synthetic_index
?.slice()
.sort((a, b) =>
a.level === 'submarket' && b.level === 'submarket'
? a.name.localeCompare(b.name)
: a.level.localeCompare(b.level)
);

const context_value = {
currency,
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/Components/api-token/api-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const ApiToken = ({ footer_ref, is_app_settings, is_switching, overlay_ref, setI
setFieldTouched,
}) => (
<Form noValidate>
<Timeline className='da-api-token__timeline'>
<Timeline className='da-api-token__timeline' line_height='xxxl'>
<Timeline.Item
item_title={localize('Select scopes based on the access you need.')}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const TwoFactorAuthentication = ({
{localize('How to set up 2FA for your Deriv account')}
</Text>
<div>
<Timeline className='two-factor__timeline'>
<Timeline className='two-factor__timeline' line_height='xxxl'>
<Timeline.Item
item_title={
<Localize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const ProofOfAddressForm = ({
}, [account_settings, fetchResidenceList, fetchStatesList, is_eu, setFormValues]);

const validateFields = values => {
Object.entries(values).forEach(([key, value]) => (values[key] = value.trim()));

setFormState({ ...form_state, ...{ should_allow_submit: false } });
const errors = {};
const validateValues = validate(errors, values);
Expand Down
1 change: 1 addition & 0 deletions packages/appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@deriv/components": "^1.0.0",
"@deriv/cfd": "^1.0.0",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/trader": "^3.8.0",
"@deriv/translations": "^1.0.0",
"@deriv/ui": "^0.0.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const AddOptions = ({ ui }: Pick<TRootStore, 'ui'>) => {
const { is_eu } = client;
const is_eu_country_text = is_eu
? 'You need to create a Multipliers account to create a CFD account.'
: 'You need to create an Options and Multipliers account to create a CFD account.';
: 'You need to create an Options and Multipliers account to add a CFD account.';

const is_eu_country_btn = is_eu
? localize('Get a Multipliers account')
Expand Down
25 changes: 14 additions & 11 deletions packages/appstore/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import classNames from 'classnames';
import * as React from 'react';
import { observer } from 'mobx-react-lite';
import { setWebsocket, routes } from '@deriv/shared';
import { StoreProvider } from '@deriv/stores';
import Routes from 'Components/routes/routes';
import { useStores, initContext } from 'Stores';
import { TRootStore } from 'Types';
Expand All @@ -21,17 +22,19 @@ const App: React.FC<TAppProps> = ({ passthrough }: TAppProps) => {
const { ui }: TRootStore = useStores();

return (
<main
className={classNames('dashboard', {
'theme--light': !ui.is_dark_mode_on,
'theme--dark': ui.is_dark_mode_on,
'dashboard-onboarding': window.location.pathname === routes.onboarding,
})}
>
<div className='dw-dashboard'>
<Routes />
</div>
</main>
<StoreProvider store={root_store as any}>
<main
className={classNames('dashboard', {
'theme--light': !ui.is_dark_mode_on,
'theme--dark': ui.is_dark_mode_on,
'dashboard-onboarding': window.location.pathname === routes.onboarding,
})}
>
<div className='dw-dashboard'>
<Routes />
</div>
</main>
</StoreProvider>
);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/appstore/src/modules/trading-hub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
CFDDbviOnBoarding,
CFDPersonalDetailsModal,
CFDResetPasswordModal,
CFDServerErrorDialog,
CFDTopUpDemoModal,
MT5TradeModal,
CFDPasswordManagerModal,
} from '@deriv/cfd';
import CFDServerErrorDialog from '@deriv/cfd/src/Containers/cfd-server-error-dialog';
import CFDAccounts from 'Components/CFDs';
import OptionsAccounts from 'Components/options';
import TotalAssets from 'Components/total-assets';
Expand Down Expand Up @@ -283,7 +283,7 @@ const TradingHub: React.FC = () => {
<CFDDbviOnBoarding context={store} />
<CFDPersonalDetailsModal context={store} />
<CFDResetPasswordModal context={store} platform={platform} />
<CFDServerErrorDialog context={store} />
<CFDServerErrorDialog />
<CFDTopUpDemoModal context={store} />
<MT5TradeModal
context={store}
Expand Down
1 change: 1 addition & 0 deletions packages/appstore/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const initContext = (core_store: TRootStore, websocket: Record<string, un
}
};

/** @deprecated Use `useStore` from `@deriv/stores` package instead. */
export const useStores = (): TRootStore => React.useContext(stores_context);
3 changes: 0 additions & 3 deletions packages/appstore/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ module.exports = function (env) {
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
use: [
{
loader: '@deriv/shared/src/loaders/react-import-loader.js',
},
{
loader: '@deriv/shared/src/loaders/deriv-trader-loader.js',
},
Expand Down
16 changes: 12 additions & 4 deletions packages/cashier/src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const payment_methods = {
'Local bank transfer',
'Local bank Transfers',
'Local deposits',
'Local deposit',
'local deposits',
'BANKTRANSFERS',
'Bank Deposits',
'Bank deposit and transfer',
Expand All @@ -187,6 +189,7 @@ const payment_methods = {
'OnlineTransfer',
'ZWbanktransfers',
'localbanktransfer',
'Bank transfer Bank wire',
],
'Bank wire': [
'bank',
Expand All @@ -212,11 +215,13 @@ const payment_methods = {
'E-wallets and bank wires',
'local bank wire',
'LocalBankWire',
'LocalBankwire',
'Wire Bank Transfer',
'WIRE TRANSFER',
'Bank Wire transfer',
'Fiat',
'OnlineTransfer',
'Bank transfer Bank wire',
],
BankABC: ['BankABC', 'BANCABC BANK'],
'Bank BTN': ['Bank BTN', 'BTN'],
Expand Down Expand Up @@ -270,7 +275,7 @@ const payment_methods = {
'cash send Absa',
'Cash send Absa bank',
],
'Chipper Cash': ['Chipper Cash', 'Chipper', 'Chippercash'],
'Chipper Cash': ['Chipper Cash', 'Chipper', 'Chippercash', 'Chipperchash'],
'CIH Bank': ['CIH Bank', 'Cih Bank'],
CIMB: ['CIMB', 'CIMBNIAGA', 'NIAGA'],
'City Hopper': ['City hopper', 'City Hopper'],
Expand All @@ -290,6 +295,7 @@ const payment_methods = {
'Cripto',
'crypto',
'Crypto',
'Cyptocurrency',
'cryptocurrencies',
'Cryptocurrencies',
'Crypto Currencies',
Expand Down Expand Up @@ -503,8 +509,9 @@ const payment_methods = {
'KudaMFB',
'KUDA MICROFINANCE BANK 2014563937',
'Kuda Microfinance',
'KUDA',
],
'Luno Wallet': ['Luno Wallet', 'Luno', 'Luno crypto wallet', 'Luno e-wallet', 'Luno ewallet'],
'Luno Wallet': ['Luno Wallet', 'Luno', 'Luno crypto wallet', 'Luno e-wallet', 'Luno ewallet', 'luno'],
'Mandiri Bank': ['Mandiri Bank', 'Mandiri', 'MANDIRI', 'MandiriSyariah', 'BankMandiri'],
'Meezan Bank': ['Meezan Bank', 'MeezanBank'],
'Millenium Bim Visa': ['Millenium Bim Visa', 'Millenium Bim'],
Expand Down Expand Up @@ -742,17 +749,18 @@ const payment_methods = {
'Ussd transfer',
'USSD transfer',
'USSD Transfer',
'ussd transfer',
],
Vodacom: ['Vodacom', 'VodacomMpesa'],
'Vodafone Cash': ['Vodafon Cash Methods', 'Vodafone cash', 'Vodafone Cash', 'VODAFONE CASH', 'VODAFONECASH'],
Webmoney: ['Perfect Money and Webmoney', 'Webmoney', 'WebMoney', 'Web Money'],
Webmoney: ['Perfect Money and Webmoney', 'Webmoney', 'WebMoney', 'Web Money', 'Web money'],
'WeChat Pay': ['WeChat Pay', 'WeChatPay'],
'Wema Bank': ['Wema Bank', 'Wema'],
WesternUnion: ['Western union', 'Western Union', 'WesternUnion', 'westernunion'],
Wise: ['Wise', 'transferwise'],
'World Remit': ['World remit', 'World Remit', 'CoinbaseworldRemit'],
'Zanaco bank': ['ZANACO', 'Zanaco bank'],
'Zenith bank': ['Zenith bank', 'Zenithbank', 'Zenith Bank', 'ZenithBank', 'ZENITH BANK', 'Zenith'],
'Zenith bank': ['Zenith bank', 'Zenithbank', 'Zenith Bank', 'ZenithBank', 'ZENITH BANK', 'Zenith', 'zenithbank'],
Zipit: ['Zipit', 'ZIPIT', 'ZIPIT bank transfers'],
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
// TODO refactor old tests in this component
import React from 'react';
import { RouteWithSubRoutesRender } from '../route-with-sub-routes';
import { MemoryRouter, Redirect } from 'react-router-dom';
import { render } from '@testing-library/react';
import { Redirect } from 'react-router-dom';
import { render, screen } from '@testing-library/react';
import RouteWithSubRoutes from '../route-with-sub-routes';

type TMockFunction = {
path: string;
exact?: boolean;
};

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
Route: jest.fn(({ path, exact }: TMockFunction) => (
<div>
<span>{`path param: ${path}`}</span>
<span>{`exact param: ${exact}`}</span>
</div>
)),
}));

afterEach(() => jest.clearAllMocks());

const mockFunction = jest.fn();
const route = {
getTitle: mockFunction,
getTitle: jest.fn(),
component: Redirect,
is_logging_in: true,
is_logged_in: true,
exact: true,
path: '/',
to: '/root',
path: '/test-path',
};

const MockComponent = () => (
<MemoryRouter>
<RouteWithSubRoutesRender {...route} />
</MemoryRouter>
);
const MockRouteWithSubRoutes = () => <RouteWithSubRoutes {...route} />;

describe('<RouteWithSubRoutes />', () => {
it('should render one <RouteWithSubRoutesRender /> component', () => {
render(<MockComponent />);
describe('RouteWithSubRoutes component', () => {
it('should render the "RouteWithSubRoutes" component', () => {
render(<MockRouteWithSubRoutes />);
const span_element = screen.getByText(/path param: \/test-path/i);
expect(span_element).toBeInTheDocument();
});
});

// import React from 'react';
// import { RouteWithSubRoutesRender } from '../route-with-sub-routes';
// import { Redirect } from 'react-router-dom';

// configure({ adapter: new Adapter() });

// describe('<RouteWithSubRoutes />', () => {
// it('should render one <RouteWithSubRoutesRender /> component', () => {
// const wrapper = shallow(<RouteWithSubRoutesRender />);
// expect(wrapper).toHaveLength(1);
// });
// it('should have props as passed as route', () => {
// const route = { path: '/', component: Redirect, title: '', exact: true, to: '/root' };
// const wrapper = shallow(<RouteWithSubRoutesRender {...route} />);
// expect(wrapper.prop('exact')).toBe(true);
// expect(wrapper.prop('path')).toBe('/');
// expect(wrapper.prop('render')).toBeInstanceOf(Function);
// });
// });
it('should render properties', () => {
render(<MockRouteWithSubRoutes />);
const path_param = screen.getByText(/\/test-path/i);
const exact_param = screen.getByText(/exact param: true/i);
expect(path_param).toBeInTheDocument();
expect(exact_param).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,4 @@ const RouteWithSubRoutes = (route: TRouteWithSubRoutesProps) => {
return <Route exact={route.exact} path={route.path} render={renderFactory} />;
};

export { RouteWithSubRoutes as RouteWithSubRoutesRender }; // For tests

export default RouteWithSubRoutes;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ const PaymentAgentCardDescription = ({ is_dark_mode_on, payment_agent }) => {
line_height='s'
size='xs'
>
{capitalizeFirstLetter(payment_agent.further_information)}
{capitalizeFirstLetter(payment_agent.further_information).replace(
/( ?Skril?l,? ?)|( ?Net?tel?ler,? ?)/gi,
''
)}
</Text>
)}
{payment_agent_urls && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const WithdrawalTab = observer(() => {
if (payment_agent.active_tab_index && !verification_code) {
verify.send();
}
}, [payment_agent.active_tab_index, verification_code, verify]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [payment_agent.active_tab_index, verification_code]);
// TODO: `verify` should not be a dependency of the `useEffect` hook as it will cause a loop,
// We shouldn't call `verify.send()` inside the `useEffect` and we should improve the UX to
// match the behavior of the `Withdrawal` page and first inform the user.

if (verify.error && 'code' in verify.error) return <PaymentAgentWithdrawalLocked error={verify.error} />;
if (!verify.is_loading && verify.has_been_sent)
Expand Down
10 changes: 10 additions & 0 deletions packages/cfd/@deriv-stores.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { TRootStore } from '@deriv/stores/types';
import type CFDStore from './src/Stores/Modules/CFD/cfd-store';

declare module '@deriv/stores' {
export function useStore(): TRootStore & {
modules: {
cfd: CFDStore;
};
};
}
3 changes: 0 additions & 3 deletions packages/cfd/build/loaders-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');

const js_loaders = [
{
loader: '@deriv/shared/src/loaders/react-import-loader.js',
},
{
loader: '@deriv/shared/src/loaders/deriv-account-loader.js',
},
Expand Down
1 change: 1 addition & 0 deletions packages/cfd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.8",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/translations": "^1.0.0",
"@types/classnames": "^2.2.11",
"@types/react-loadable": "^5.5.6",
Expand Down
Loading

0 comments on commit de81fd4

Please sign in to comment.