Skip to content

Commit 13d0f58

Browse files
thisyahlen/TRAH-2825/chore: general code improvements and text style fix (#13411)
* chore: style fixes * chore: code cleanup and text as p * chore: update * chore: cleanup * chore: revert create password
1 parent 51ee8aa commit 13d0f58

File tree

27 files changed

+87
-110
lines changed

27 files changed

+87
-110
lines changed

packages/tradershub/src/AppContent.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import React from 'react';
2-
import { EUDisclaimerMessage, useUIContext } from '@/components';
2+
import { EUDisclaimerMessage } from '@/components';
33
import { useRegulationFlags } from '@/hooks';
44
import { Router } from '@/routes';
55
import SignupWizard from './flows/RealAccountSIgnup/SignupWizard';
66

77
const AppContent = () => {
8-
const { uiState } = useUIContext();
9-
const activeRegulation = uiState.regulation;
10-
const { isEU } = useRegulationFlags(activeRegulation);
8+
const { isEU } = useRegulationFlags();
119

1210
return (
1311
<div className='h-full-mobile lg:h-full-desktop'>

packages/tradershub/src/components/CFDSection/CFDContent/CFDContent.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import React from 'react';
2-
import { TradingAppCardLoader, useUIContext } from '@/components';
2+
import { TradingAppCardLoader } from '@/components';
33
import { useRegulationFlags } from '@/hooks';
44
import { CTraderList, MT5PlatformsList, OtherCFDPlatformsList } from '@cfd/components';
55
import { useIsEuRegion } from '@deriv/api';
66

77
const CFDContent = () => {
88
const { isSuccess: isRegulationAccessible } = useIsEuRegion();
9-
const { uiState } = useUIContext();
109

11-
const activeRegulation = uiState.regulation;
12-
13-
const { isEU } = useRegulationFlags(activeRegulation);
10+
const { isEU } = useRegulationFlags();
1411

1512
if (!isRegulationAccessible)
1613
return (

packages/tradershub/src/components/CFDSection/CFDHeading/CFDHeading.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import React, { Fragment } from 'react';
22
import { useHistory } from 'react-router-dom';
3-
import { StaticLink, TitleDescriptionLoader, useUIContext } from '@/components';
3+
import { StaticLink, TitleDescriptionLoader } from '@/components';
44
import { useRegulationFlags } from '@/hooks';
55
import { useIsEuRegion } from '@deriv/api';
66
import { Button, Heading, qtMerge, useBreakpoint } from '@deriv/quill-design';
77
import { Text } from '@deriv-com/ui';
88

99
const CompareAccountsButton = ({ className }: { className?: string }) => {
1010
const history = useHistory();
11-
const { uiState } = useUIContext();
12-
const { accountType, regulation } = uiState;
1311

14-
const { isEU } = useRegulationFlags(regulation, accountType);
12+
const { isEU } = useRegulationFlags();
1513

1614
const title = isEU ? 'Account information' : 'Compare Accounts';
1715

packages/tradershub/src/components/CFDSection/CFDSection.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import React from 'react';
2-
import { useUIContext } from '@/components';
32
import { useRegulationFlags } from '@/hooks';
43
import { GetADerivAccountBanner } from '../GetADerivAccountBanner';
54
import { CFDContent } from './CFDContent';
65
import { CFDHeading } from './CFDHeading';
76

87
const CFDSection = () => {
9-
const { uiState } = useUIContext();
10-
const { accountType, regulation } = uiState;
11-
const { isSuccess, noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags(regulation, accountType);
8+
const { isSuccess, noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags();
129

1310
return (
1411
<div className='overflow-y-scroll border-solid pt-800 lg:p-1200 rounded-1200 lg:border-xs lg:border-opacity-black-100'>

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { useHistory } from 'react-router-dom';
3-
import { CurrencySwitcherLoader, Modal, TradingAccountsList, useUIContext } from '@/components';
3+
import { CurrencySwitcherLoader, Modal, TradingAccountsList } from '@/components';
44
import { IconToCurrencyMapper } from '@/constants';
55
import { useRegulationFlags } from '@/hooks';
66
import { THooks } from '@/types';
@@ -44,11 +44,8 @@ const CurrencySwitcher = () => {
4444
const { data: activeAccount, isSuccess } = useActiveTradingAccount();
4545
const isDemo = activeAccount?.is_virtual;
4646
const { show } = Provider.useModal();
47-
const { uiState } = useUIContext();
4847

49-
const { accountType, regulation } = uiState;
50-
51-
const { noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags(regulation, accountType);
48+
const { noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags();
5249

5350
const iconCurrency = isDemo ? 'virtual' : activeAccount?.currency ?? 'virtual';
5451

@@ -61,6 +58,7 @@ const CurrencySwitcher = () => {
6158
<div className='flex-none '>{IconToCurrencyMapper[iconCurrency].icon}</div>
6259
<div className='grow'>
6360
<Text
61+
as='p'
6462
className={isDemo ? 'text-status-light-information' : 'text-system-light-less-prominent-text'}
6563
size='sm'
6664
weight={isDemo ? 'bold' : 'normal'}

packages/tradershub/src/components/DemoRealSwitcher/DemoRealSwitcher.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const DemoRealSwitcher = () => {
105105
role='button'
106106
>
107107
<Text
108+
as='p'
108109
className='text-center px-800 py-300'
109110
size='sm'
110111
weight={account.value === value ? 'bold' : 'normal'}

packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountDialog.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { Button } from '@deriv/quill-design';
3-
import { Text } from '@deriv-com/ui';
2+
import { Provider } from '@deriv/library';
3+
import { Button, Text } from '@deriv-com/ui';
4+
import { useSignupWizardContext } from '../../providers/SignupWizardProvider';
45
import { Dialog } from '../Dialog';
56

67
/**
@@ -10,17 +11,25 @@ import { Dialog } from '../Dialog';
1011
* @returns {React.ReactElement} A `<Dialog>` component containing the dialog message and action button.
1112
*/
1213
const GetADerivAccountDialog = () => {
14+
const { hide } = Provider.useModal();
15+
const { setIsWizardOpen } = useSignupWizardContext();
16+
1317
return (
1418
<Dialog className='lg:w-[440px]'>
1519
<Dialog.Header heading='h5' hideCloseButton title="You'll need a Deriv account" />
1620
<Dialog.Content>
17-
<Text size='sm'>A Deriv account will allow you to fund (and withdraw from) your MT5 account(s). </Text>
21+
<Text size='sm'>A Deriv account will allow you to fund (and withdraw from) your CFDs account(s). </Text>
1822
</Dialog.Content>
1923
<Dialog.Action align='right'>
20-
<Button className='rounded-200 h-2000 px-500' colorStyle='black' size='md' variant='secondary'>
24+
<Button onClick={hide} variant='outlined'>
2125
Cancel
2226
</Button>
23-
<Button className='rounded-200 h-2000 px-500' colorStyle='coral' size='md' variant='primary'>
27+
<Button
28+
onClick={() => {
29+
hide();
30+
setIsWizardOpen(true);
31+
}}
32+
>
2433
Add a Deriv account
2534
</Button>
2635
</Dialog.Action>

packages/tradershub/src/components/GetDerivAccount/GetDerivAccount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const TrailingButton = () => {
88
return <TradingAccountCardLightButton onSubmit={() => setIsWizardOpen(true)} />;
99
};
1010

11-
const LeadingIcon = () => <PlatformIcon icon='DerivApps' />;
11+
const LeadingIcon = () => <PlatformIcon icon='DerivApps' width={60} />;
1212

1313
const GetDerivAccount = () => {
1414
const title = 'Deriv account';

packages/tradershub/src/components/OptionsAndMultipliersSection/OptionsAndMultipliersContent/OptionsAndMultipliersContent.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { useHistory } from 'react-router-dom';
3-
import { TradingAccountCard, TradingAccountCardContent, TradingAppCardLoader, useUIContext } from '@/components';
3+
import { TradingAccountCard, TradingAccountCardContent, TradingAppCardLoader } from '@/components';
44
import { optionsAndMultipliersContent } from '@/constants';
55
import { getStaticUrl, getUrlBinaryBot, getUrlSmartTrader } from '@/helpers';
66
import { useRegulationFlags } from '@/hooks';
@@ -68,10 +68,7 @@ const LinkTitle = ({ icon, title }: TLinkTitleProps) => {
6868
const ShowOpenButton = ({ isExternal, redirect }: TShowButtonProps) => {
6969
const history = useHistory();
7070

71-
const { uiState } = useUIContext();
72-
const { accountType, regulation } = uiState;
73-
74-
const { noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags(regulation, accountType);
71+
const { noRealCRNonEUAccount, noRealMFEUAccount } = useRegulationFlags();
7572

7673
if (noRealCRNonEUAccount || noRealMFEUAccount) return null;
7774

@@ -99,10 +96,7 @@ const OptionsAndMultipliersContent = () => {
9996
const { data } = useActiveTradingAccount();
10097
const { isSuccess: isRegulationAccessible } = useIsEuRegion();
10198

102-
const { uiState } = useUIContext();
103-
const activeRegulation = uiState.regulation;
104-
105-
const { isEU } = useRegulationFlags(activeRegulation);
99+
const { isEU } = useRegulationFlags();
106100

107101
const getoptionsAndMultipliersContent = optionsAndMultipliersContent(isEU ?? false);
108102

packages/tradershub/src/components/OptionsAndMultipliersSection/OptionsAndMultipliersHeading/OptionsAndMultipliersHeading.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { CurrencySwitcher, StaticLink, TitleDescriptionLoader, useUIContext } from '@/components';
2+
import { CurrencySwitcher, StaticLink, TitleDescriptionLoader } from '@/components';
33
import { useRegulationFlags } from '@/hooks';
44
import { useIsEuRegion } from '@deriv/api';
55
import { Heading, useBreakpoint } from '@deriv/quill-design';
@@ -12,9 +12,7 @@ import { Text } from '@deriv-com/ui';
1212
const OptionsAndMultipliersHeading = () => {
1313
const { isMobile } = useBreakpoint();
1414
const { isSuccess: isRegulationAccessible } = useIsEuRegion();
15-
const { uiState } = useUIContext();
16-
const activeRegulation = uiState.regulation;
17-
const { isEU } = useRegulationFlags(activeRegulation);
15+
const { isEU } = useRegulationFlags();
1816

1917
const title = isEU ? 'Multipliers' : 'Options & multipliers';
2018

0 commit comments

Comments
 (0)