Skip to content

Commit 55397a6

Browse files
[FEQ] / Ameerul / FEQ-1977 Refactor my profile page (deriv-com#14331)
* fix: ui issues in my-profile and create new ad button * fix: styling issues * fix: failing test cases * chore: remove PaymentMethodsHeader component and fix minor style issues * chore: replace Table component with deriv-com/ui one * fix: removed unused prop isFloating * chore: removed text * chore: refactored PaymentMethodForm, separated components out * chore: refactored PaymentMethodModals * fix: style discrepencies in BuySellModal * chore: removed Text and unused imports * chore: added suggestions * chore: added LightDivider component * fix: ui issues for share-my-ads-modal, dropdown in myadsrow, my-ads-delete-modal * fix: header padding ShareAdsModal * chore: removed color from LightDivider, changed prop name * chore: renamed PaymentMethodFormInput to PaymentMethodFormAutocomplete
1 parent f095005 commit 55397a6

File tree

86 files changed

+930
-653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+930
-653
lines changed

packages/p2p-v2/src/components/BuySellForm/BuySellAmount/BuySellAmount.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { useEffect, useState } from 'react';
22
import { Controller, useForm } from 'react-hook-form';
3+
import { LightDivider } from '@/components';
34
import { floatingPointValidator } from '@/utils';
4-
import { Divider, Input, Text, useDevice } from '@deriv-com/ui';
5+
import { Input, Text, useDevice } from '@deriv-com/ui';
56
import { FormatUtils } from '@deriv-com/utils';
67
import './BuySellAmount.scss';
78

@@ -42,7 +43,7 @@ const BuySellAmount = ({
4243

4344
return (
4445
<div className='flex flex-col gap-[2rem] py-[2.4rem]'>
45-
<Text className='px-[2.4rem]' color='less-prominent' size={labelSize}>
46+
<Text className='px-[2.4rem]' color='less-prominent' size='sm'>
4647
{`Enter ${isBuy ? 'sell' : 'buy'} amount`}
4748
</Text>
4849
<div className='p2p-v2-buy-sell-amount__input-wrapper'>
@@ -93,10 +94,10 @@ const BuySellAmount = ({
9394
required: 'Enter a valid amount',
9495
}}
9596
/>
96-
{isMobile && <Divider />}
97+
{isMobile && <LightDivider />}
9798
<div className='flex flex-col w-full px-[2.4rem]'>
9899
<Text color='less-prominent' size={labelSize}>{`You'll ${isBuy ? 'receive' : 'send'}`}</Text>
99-
<Text size={labelSize} weight='bold'>
100+
<Text size={isMobile ? 'md' : 'sm'} weight='bold'>
100101
{buySellAmount} {localCurrency}
101102
</Text>
102103
</div>

packages/p2p-v2/src/components/BuySellForm/BuySellForm.scss

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
position: absolute;
2828
top: -4rem;
2929
left: 0;
30-
background: #fff;
3130
z-index: 1;
3231
height: calc(100vh - 8rem);
3332

packages/p2p-v2/src/components/BuySellForm/BuySellForm.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
setDecimalPlaces,
1313
} from '@/utils';
1414
import { p2p } from '@deriv/api-v2';
15-
import { Divider, InlineMessage, Text, TextArea, useDevice } from '@deriv-com/ui';
15+
import { InlineMessage, Text, TextArea, useDevice } from '@deriv-com/ui';
16+
import { LightDivider } from '../LightDivider';
1617
import { BuySellAmount } from './BuySellAmount';
1718
import { BuySellData } from './BuySellData';
1819
import BuySellFormDisplayWrapper from './BuySellFormDisplayWrapper';
@@ -184,7 +185,7 @@ const BuySellForm = ({
184185
paymentMethods={paymentMethods}
185186
rate={displayEffectiveRate}
186187
/>
187-
<Divider />
188+
<LightDivider />
188189
{isBuy && payment_method_names?.length > 0 && (
189190
<BuySellPaymentSection
190191
availablePaymentMethods={availablePaymentMethods}
@@ -240,7 +241,7 @@ const BuySellForm = ({
240241
)}
241242
{isBuy && (
242243
<>
243-
<Divider />
244+
<LightDivider />
244245
<Controller
245246
control={control}
246247
name='contact_details'
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import React from 'react';
2-
import { Text } from '@deriv-com/ui';
2+
import { Text, useDevice } from '@deriv-com/ui';
33

44
type TBuySellFormHeaderProps = {
55
currency?: string;
66
isBuy: boolean;
77
};
8-
const BuySellFormHeader = ({ currency = '', isBuy }: TBuySellFormHeaderProps) => (
9-
<Text size='lg' weight='bold'>
10-
{`${isBuy ? 'Sell' : 'Buy'} ${currency}`}
11-
</Text>
12-
);
8+
9+
const BuySellFormHeader = ({ currency = '', isBuy }: TBuySellFormHeaderProps) => {
10+
const { isMobile } = useDevice();
11+
12+
return (
13+
<Text size={isMobile ? 'lg' : 'md'} weight='bold'>
14+
{`${isBuy ? 'Sell' : 'Buy'} ${currency}`}
15+
</Text>
16+
);
17+
};
1318

1419
export default BuySellFormHeader;

packages/p2p-v2/src/components/BuySellForm/BuySellFormHeader/__tests__/BuySellFormHeader.spec.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const mockProps = {
77
isBuy: true,
88
};
99

10+
jest.mock('@deriv-com/ui', () => ({
11+
...jest.requireActual('@deriv-com/ui'),
12+
useDevice: () => ({ isMobile: false }),
13+
}));
14+
1015
describe('BuySellFormHeader', () => {
1116
it('should render the header as expected', () => {
1217
render(<BuySellFormHeader {...mockProps} />);

packages/p2p-v2/src/components/BuySellForm/BuySellPaymentSection/BuySellPaymentSection.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import { TPaymentMethod } from 'types';
3+
import { LightDivider } from '@/components';
34
import { sortPaymentMethodsWithAvailability } from '@/utils';
4-
import { Divider, Text, useDevice } from '@deriv-com/ui';
5+
import { Text, useDevice } from '@deriv-com/ui';
56
import { PaymentMethodCard } from '../../PaymentMethodCard';
67

78
type TBuySellPaymentSectionProps = {
@@ -70,7 +71,7 @@ const BuySellPaymentSection = ({
7071
))}
7172
</div>
7273
</div>
73-
<Divider />
74+
<LightDivider />
7475
</>
7576
);
7677
};

packages/p2p-v2/src/components/Clipboard/Clipboard.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
align-items: center;
77
justify-content: center;
88
cursor: pointer;
9-
height: 4.8rem;
10-
width: 3.8rem;
9+
height: 3.8rem;
10+
width: 3.2rem;
1111
}

packages/p2p-v2/src/components/Clipboard/Clipboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const Clipboard = ({ textCopy }: TClipboardProps) => {
3333
}, []);
3434

3535
return (
36-
<Tooltip message={isCopied ? 'Copied!' : 'Copy'} position='right'>
36+
<Tooltip message={isCopied ? 'Copied!' : 'Copy'} position='top'>
3737
<button className='p2p-v2-clipboard' onClick={onClick}>
3838
{isCopied ? <CheckmarkCircle /> : <CopyIcon />}
3939
</button>

packages/p2p-v2/src/components/FullPageMobileWrapper/FullPageMobileWrapper.scss

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
border-radius: 0;
66
display: grid;
77
grid-template-rows: 6rem auto;
8+
background-color: #fff;
89

910
&--fixed-footer {
1011
grid-template-rows: 6rem auto 8rem;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { Divider } from '@deriv-com/ui';
3+
4+
type TLightDividerProps = {
5+
className?: string;
6+
height?: string;
7+
margin?: string;
8+
};
9+
10+
const LightDivider = ({ className, height, margin }: TLightDividerProps) => {
11+
return <Divider className={className} color='#f2f3f4' height={height} margin={margin} />;
12+
};
13+
14+
export default LightDivider;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as LightDivider } from './LightDivider';

packages/p2p-v2/src/components/MobileTabs/MobileTabs.scss

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
display: flex;
33
flex-direction: column;
44

5-
.derivs-button {
6-
padding: 2.3rem 1.6rem;
5+
&__tab {
6+
padding: 3rem 1.6rem;
77
display: flex;
88
justify-content: space-between;
9-
border-bottom: 0.1rem solid #e6e9e9;
9+
border-bottom: 0.1rem solid #f2f3f4;
1010
flex-direction: row-reverse;
11+
border-radius: unset;
1112

1213
&:last-child {
1314
border-bottom: none;

packages/p2p-v2/src/components/MobileTabs/MobileTabs.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { LabelPairedChevronRightLgBoldIcon } from '@deriv/quill-icons';
3-
import { Button } from '@deriv-com/ui';
2+
import { LabelPairedChevronRightSmRegularIcon } from '@deriv/quill-icons';
3+
import { Button, Text } from '@deriv-com/ui';
44
import './MobileTabs.scss';
55

66
type TMobileTabsProps<T extends string[]> = {
@@ -15,12 +15,12 @@ function MobileTabs<T extends string[]>({ onChangeTab, tabs }: TMobileTabsProps<
1515
<Button
1616
className='p2p-v2-mobile-tabs__tab'
1717
color='white'
18-
icon={<LabelPairedChevronRightLgBoldIcon />}
18+
icon={<LabelPairedChevronRightSmRegularIcon />}
1919
key={`${tab}-${i}`}
2020
onClick={() => onChangeTab(tab)}
2121
variant='contained'
2222
>
23-
{tab}
23+
<Text size='sm'>{tab}</Text>
2424
</Button>
2525
))}
2626
</div>

packages/p2p-v2/src/components/Modals/BlockUnblockUserModal/BlockUnblockUserModal.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ const BlockUnblockUserModal = ({
5959
{getModalContent()}
6060
</Text>
6161
<div className='p2p-v2-block-unblock-user-modal__footer'>
62-
<Button onClick={onRequestClose} size='lg' textSize='sm' variant='outlined'>
62+
<Button
63+
className='border-2'
64+
color='black'
65+
onClick={onRequestClose}
66+
size='lg'
67+
textSize='sm'
68+
variant='outlined'
69+
>
6370
Cancel
6471
</Button>
6572
<Button onClick={onClickBlockUnblock} size='lg' textSize='sm'>

packages/p2p-v2/src/components/Modals/FilterModal/FilterModal.scss

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@include mobile {
88
position: absolute;
99
top: -4rem;
10-
background: #fff;
1110
z-index: 1;
1211
height: calc(100vh - 8rem);
1312
}

packages/p2p-v2/src/components/Modals/FilterModal/FilterModalFooter/FilterModalFooter.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Button, Text, useDevice } from '@deriv-com/ui';
2+
import { Button, useDevice } from '@deriv-com/ui';
33
import './FilterModalFooter.scss';
44

55
type TFilterModalFooterProps = {
@@ -30,21 +30,19 @@ const FilterModalFooter = ({
3030
isFullWidth={isMobile}
3131
onClick={onResetClear}
3232
size='lg'
33+
textSize={isMobile ? 'md' : 'sm'}
3334
variant='outlined'
3435
>
35-
<Text lineHeight='6xl' size='sm' weight='bold'>
36-
{showPaymentMethods ? 'Clear' : 'Reset'}
37-
</Text>
36+
{showPaymentMethods ? 'Clear' : 'Reset'}
3837
</Button>
3938
<Button
4039
disabled={(showPaymentMethods && hasSamePaymentMethods) || (!showPaymentMethods && hasSameFilters)}
4140
isFullWidth={isMobile}
4241
onClick={onApplyConfirm}
4342
size='lg'
43+
textSize={isMobile ? 'md' : 'sm'}
4444
>
45-
<Text lineHeight='6xl' size='sm' weight='bold'>
46-
{showPaymentMethods ? 'Confirm' : 'Apply'}
47-
</Text>
45+
{showPaymentMethods ? 'Confirm' : 'Apply'}
4846
</Button>
4947
</div>
5048
);
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
.p2p-v2-my-ads-delete-modal {
2-
@include p2p-v2-modal-styles;
2+
height: auto;
33
width: 44rem;
4+
border-radius: 8px;
5+
46
@include mobile {
57
width: 32.8rem;
68
}
9+
710
&__header {
8-
margin: 0 0.8rem;
9-
padding-bottom: 1.2rem;
1011
@include mobile {
11-
margin: 0;
12+
padding: 0 1.6rem;
1213
}
1314
}
15+
1416
&__body {
15-
margin: 2.4rem 0.8rem;
17+
padding: 1rem 2.4rem;
1618
@include mobile {
17-
margin: 0;
19+
padding: 0 1.6rem;
20+
}
21+
}
22+
23+
&__footer {
24+
@include mobile {
25+
padding: 1.6rem;
1826
}
1927
}
2028
}

packages/p2p-v2/src/components/Modals/MyAdsDeleteModal/MyAdsDeleteModal.tsx

+32-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import React, { memo, useEffect } from 'react';
2-
import Modal from 'react-modal';
1+
import React, { memo } from 'react';
32
import { useDevice } from '@/hooks';
43
import { p2p } from '@deriv/api-v2';
5-
import { Button, Text } from '@deriv-com/ui';
6-
import { customStyles } from '../helpers';
4+
import { Button, Modal, Text } from '@deriv-com/ui';
75
import './MyAdsDeleteModal.scss';
86

97
type TMyAdsDeleteModalProps = {
@@ -21,10 +19,6 @@ const MyAdsDeleteModal = ({ error, id, isModalOpen, onClickDelete, onRequestClos
2119

2220
const hasActiveOrders = advertInfo?.active_orders && advertInfo?.active_orders > 0;
2321

24-
useEffect(() => {
25-
Modal.setAppElement('#v2_modal_root');
26-
}, []);
27-
2822
const getModalText = () => {
2923
if (hasActiveOrders && !error) {
3024
return 'You have open orders for this ad. Complete all open orders before deleting this ad.';
@@ -37,17 +31,22 @@ const MyAdsDeleteModal = ({ error, id, isModalOpen, onClickDelete, onRequestClos
3731
const getModalFooter = () => {
3832
if (hasActiveOrders || error) {
3933
return (
40-
<div className='flex justify-end'>
41-
<Button onClick={onRequestClose} size='lg' textSize={textSize}>
42-
Ok
43-
</Button>
44-
</div>
34+
<Button onClick={onRequestClose} size='lg' textSize={textSize}>
35+
Ok
36+
</Button>
4537
);
4638
}
4739

4840
return (
49-
<div className='flex justify-end gap-[1rem] pt-[1.6rem]'>
50-
<Button onClick={onRequestClose} size='lg' textSize={textSize} variant='outlined'>
41+
<div className='flex gap-[0.8rem]'>
42+
<Button
43+
className='border-2'
44+
color='black'
45+
onClick={onRequestClose}
46+
size='lg'
47+
textSize={textSize}
48+
variant='outlined'
49+
>
5150
Cancel
5251
</Button>
5352
<Button onClick={onClickDelete} size='lg' textSize={textSize}>
@@ -60,20 +59,29 @@ const MyAdsDeleteModal = ({ error, id, isModalOpen, onClickDelete, onRequestClos
6059
<>
6160
{!isLoadingInfo && (
6261
<Modal
63-
className='p-[1.6rem] p2p-v2-my-ads-delete-modal'
62+
ariaHideApp={false}
63+
className='p2p-v2-my-ads-delete-modal'
6464
isOpen={isModalOpen}
6565
onRequestClose={onRequestClose}
6666
shouldCloseOnOverlayClick={false}
67-
style={customStyles}
6867
testId='dt_p2p_v2_ads_delete_modal'
6968
>
70-
<Text as='div' className='p2p-v2-my-ads-delete-modal__header' color='general' weight='bold'>
71-
Do you want to delete this ad?
72-
</Text>
73-
<Text as='div' className='p2p-v2-my-ads-delete-modal__body' color='prominent' size='sm'>
74-
{getModalText()}
75-
</Text>
76-
{getModalFooter()}
69+
<Modal.Header
70+
className='p2p-v2-my-ads-delete-modal__header'
71+
hideBorder
72+
hideCloseIcon
73+
onRequestClose={onRequestClose}
74+
>
75+
<Text weight='bold'>Do you want to delete this ad?</Text>
76+
</Modal.Header>
77+
<Modal.Body className='p2p-v2-my-ads-delete-modal__body'>
78+
<Text color='prominent' size='sm'>
79+
{getModalText()}
80+
</Text>
81+
</Modal.Body>
82+
<Modal.Footer className='p2p-v2-my-ads-delete-modal__footer' hideBorder>
83+
{getModalFooter()}
84+
</Modal.Footer>
7785
</Modal>
7886
)}
7987
</>

0 commit comments

Comments
 (0)