Skip to content

Commit eda6249

Browse files
chore: add providers to tradershub from deriv/library
1 parent da55266 commit eda6249

File tree

9 files changed

+26
-27
lines changed

9 files changed

+26
-27
lines changed

packages/tradershub/src/App.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import React, { FC } from 'react';
22
import { APIProvider } from '@deriv/api';
3-
import { BreakpointProvider } from '@deriv/quill-design';
3+
import { Provider } from '@deriv/library';
44
import AppContent from './AppContent';
5-
import { ModalProvider } from './components';
65
import './index.scss';
76

87
const App: FC = () => (
98
<APIProvider standalone>
10-
<BreakpointProvider>
11-
<ModalProvider>
9+
<Provider.ModalProvider>
10+
<Provider.CFDProvider>
1211
<AppContent />
13-
</ModalProvider>
14-
</BreakpointProvider>
12+
</Provider.CFDProvider>
13+
</Provider.ModalProvider>
1514
</APIProvider>
1615
);
1716

packages/tradershub/src/components/CurrencySwitcher/CurrencySwitcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { useHistory } from 'react-router-dom';
33
import { useActiveTradingAccount, useResetVirtualBalance } from '@deriv/api';
4+
import { Provider } from '@deriv/library';
45
import { Button, qtMerge, Text } from '@deriv/quill-design';
56
import { StandaloneChevronDownBoldIcon } from '@deriv/quill-icons';
67
import { IconToCurrencyMapper } from '../../constants/constants';
78
import { THooks } from '../../types';
8-
import { useModal } from '../ModalProvider';
99
import { ModalStepWrapper } from '../ModalStepWrapper';
1010
import { TradingAccountsList } from '../TradingAccountsList';
1111

@@ -45,7 +45,7 @@ const AccountActionButton = ({ balance, isDemo }: AccountActionButtonProps) => {
4545
const CurrencySwitcher = () => {
4646
const { data: activeAccount } = useActiveTradingAccount();
4747
const isDemo = activeAccount?.is_virtual;
48-
const { show } = useModal();
48+
const { show } = Provider.useModal();
4949

5050
const iconCurrency = isDemo ? 'virtual' : activeAccount?.currency ?? 'virtual';
5151

packages/tradershub/src/components/Dialog/Dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { ReactElement } from 'react';
22
import { useEventListener } from 'usehooks-ts';
3+
import { Provider } from '@deriv/library';
34
import { qtMerge } from '@deriv/quill-design';
4-
import { useModal } from '../ModalProvider';
55
import DialogAction from './DialogAction';
66
import DialogContent from './DialogContent';
77
import DialogHeader from './DialogHeader';
@@ -45,7 +45,7 @@ type TDialog = {
4545
* ```
4646
*/
4747
const Dialog = ({ children, className, shouldPreventCloseOnEscape = false }: TDialog) => {
48-
const { hide } = useModal();
48+
const { hide } = Provider.useModal();
4949

5050
useEventListener('keydown', (event: KeyboardEvent) => {
5151
if (!shouldPreventCloseOnEscape && event.key === 'Escape') {

packages/tradershub/src/components/Dialog/DialogHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2+
import { Provider } from '@deriv/library';
23
import { Heading, qtMerge } from '@deriv/quill-design';
34
import CloseIcon from '../../public/images/ic-close-dark.svg';
4-
import { useModal } from '../ModalProvider';
55

66
/**
77
* Type for the DialogHeader component props
@@ -22,7 +22,7 @@ type TDialogHeader = {
2222
* @returns {JSX.Element} The DialogHeader component.
2323
*/
2424
const DialogHeader = ({ className, hideCloseButton = false, title }: TDialogHeader) => {
25-
const { hide } = useModal();
25+
const { hide } = Provider.useModal();
2626

2727
return (
2828
<div className={qtMerge('flex items-start', title ? 'justify-between' : 'justify-end', className)}>

packages/tradershub/src/components/ModalStepWrapper/ModalStepWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { FC, PropsWithChildren, ReactNode, useEffect } from 'react';
22
import classNames from 'classnames';
33
import { useEventListener } from 'usehooks-ts';
4+
import { Provider } from '@deriv/library';
45
import { Text } from '@deriv/quill-design';
56
import CloseIcon from '../../public/images/ic-close-dark.svg';
6-
import { useModal } from '../ModalProvider';
77
import './ModalStepWrapper.scss';
88

99
type TModalStepWrapperProps = {
@@ -24,7 +24,7 @@ const ModalStepWrapper: FC<PropsWithChildren<TModalStepWrapperProps>> = ({
2424
shouldPreventCloseOnEscape = false,
2525
title,
2626
}) => {
27-
const { hide, setModalOptions } = useModal();
27+
const { hide, setModalOptions } = Provider.useModal();
2828
const hasRenderFooter = typeof renderFooter === 'function';
2929
const fixedFooter = shouldFixedFooter && hasRenderFooter;
3030

packages/tradershub/src/features/cfd/modals/MT5AccountTypeModal/MT5AccountTypeModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { ComponentProps, useState } from 'react';
2+
import { Provider } from '@deriv/library';
23
import { Button } from '@deriv/quill-design';
34
import { ModalStepWrapper } from '../../../../components';
4-
import { useModal } from '../../../../components/ModalProvider';
55
import { MT5AccountType } from '../../screens';
66

77
type TMarketTypes = ComponentProps<typeof MT5AccountType>['selectedMarketType'];
88

99
const MT5AccountTypeModal = () => {
1010
const [selectedMarketType, setSelectedMarketType] = useState<TMarketTypes>(undefined);
11-
const { setModalState } = useModal();
11+
const { setCfdState } = Provider.useCFDContext();
1212

1313
return (
1414
<ModalStepWrapper
@@ -17,7 +17,7 @@ const MT5AccountTypeModal = () => {
1717
colorStyle='coral'
1818
disabled={!selectedMarketType}
1919
onClick={() => {
20-
setModalState('marketType', selectedMarketType);
20+
setCfdState('marketType', selectedMarketType);
2121
}}
2222
size='md'
2323
variant='primary'

packages/tradershub/src/features/cfd/screens/GetMoreMT5Accounts/GetMoreMT5Accounts.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React, { FC } from 'react';
2+
import { Provider } from '@deriv/library';
23
import { Text } from '@deriv/quill-design';
3-
import { useModal } from '../../../../components/ModalProvider';
44
import AddIcon from '../../../../public/images/add-icon.svg';
55
import { MT5AccountTypeModal } from '../../modals';
66

77
const GetMoreMT5Accounts: FC = () => {
8-
const { show } = useModal();
8+
const { show } = Provider.useModal();
99

1010
return (
1111
<div
12-
className='flex items-start cursor-pointer w-full lg:w-1/3'
12+
className='flex items-start w-full cursor-pointer lg:w-1/3'
1313
onClick={() => show(<MT5AccountTypeModal />)}
1414
onKeyDown={e => {
1515
if (e.key === 'Enter') {
@@ -19,7 +19,7 @@ const GetMoreMT5Accounts: FC = () => {
1919
role='button'
2020
tabIndex={0}
2121
>
22-
<div className='flex p-800 items-center self-stretch rounded-lg border-system-light-active-background flex-1 gap-800 border-75 border-dashed'>
22+
<div className='flex items-center self-stretch flex-1 border-dashed rounded-lg p-800 border-system-light-active-background gap-800 border-75'>
2323
<div className='w-12 h-12'>
2424
<AddIcon />
2525
</div>

packages/tradershub/src/features/cfd/screens/Jurisdiction/JurisdictionTncSection/JurisdictionTncSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { FC } from 'react';
2+
import { Provider } from '@deriv/library';
23
import { Link, Text, useBreakpoint } from '@deriv/quill-design';
3-
import { useModal } from '../../../../../components/ModalProvider';
44
import { getStaticUrl } from '../../../../../helpers/urls';
55
import { THooks } from '../../../../../types';
66
import { companyNamesAndUrls } from '../../../constants';
@@ -24,8 +24,8 @@ type TProps = {
2424

2525
const JurisdictionTncSection: FC<TProps> = ({ isCheckBoxChecked, selectedJurisdiction, setIsCheckBoxChecked }) => {
2626
const { isMobile } = useBreakpoint();
27-
const { getModalState } = useModal();
28-
const marketType = getModalState('marketType') || 'all';
27+
const { getCFDState } = Provider.useCFDContext();
28+
const marketType = getCFDState('marketType') || 'all';
2929
const selectedCompany = companyNamesAndUrls[selectedJurisdiction as keyof typeof companyNamesAndUrls];
3030

3131
return (

packages/tradershub/src/features/cfd/screens/VerificationFailed/VerificationFailed.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { usePOA, usePOI } from '@deriv/api';
3+
import { Provider } from '@deriv/library';
34
import { Button, Text } from '@deriv/quill-design';
4-
import { useModal } from '../../../../components/ModalProvider';
55

66
const getDocumentTitle = (isPOIFailed?: boolean, isPOAFailed?: boolean) => {
77
if (isPOIFailed && isPOAFailed) return 'proof of identity and proof of address';
@@ -16,7 +16,7 @@ const reasons = ['Document details do not match profile details', 'Expired docum
1616
*/
1717

1818
const VerificationFailed = () => {
19-
const { hide } = useModal();
19+
const { hide } = Provider.useModal();
2020
const { data: poiStatus } = usePOI();
2121
const { data: poaStatus } = usePOA();
2222

@@ -34,7 +34,7 @@ const VerificationFailed = () => {
3434
</Text>
3535
<ul>
3636
{reasons.map(reason => (
37-
<li className=' left-500 relative list-disc' key={reason}>
37+
<li className='relative list-disc left-500' key={reason}>
3838
<Text size='sm'>{reason}</Text>
3939
</li>
4040
))}

0 commit comments

Comments
 (0)