-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEQ] Jim/FEQ-1388/payment methods (#12967)
* chore: remove fields transformation logic from usepaymentmethods hook * chore: update config * chore: temporarily add wallets components * feat: add flyout component * feat: add payment method card * chore: replace classnames with clsx * chore: fix style issues * chore: rename files * chore: update fullwidthmobilewrapper margin * chore: revert changes to fullpagemobilewrapper * chore: shift styles to respective component files * chore: add comment to show that the wallets related components should be deleted * chore: remove unnecessary commented code * chore: delete test cases for temporary components * chore: fix spacing issue for payment methods card * chore: add floating label to textarea component * chore: disable charater counter by default * chore: add react-modal * chore: add package-lock * chore: update styles * chore: correct typo * chore: update package and add isDirty and isSubmitting checks * chore: restore value to currentValue * chore: downgrade ui library version * chore: add modals * feat: add reducer and provider for advertiserpaymentmethods * chore: fix placeholder issue on textarea * chore: upgrade ui package * chore: update deriv-com/ui package * chore: add package-lock * chore: style lable for textarea with a value * chore: delete file with wrong name * chore: rename files * chore: remmove duplicate files * chore: remove duplicate files * Delete packages/p2p-v2/src/components/FlyOut directory * Delete packages/p2p-v2/src/components/Dropdown/dropdown.scss * chore: add app element * chore: remove div * chore: remove unnecessary attributes * chore: remove unnecessary attributes * chore: address reviews and fix self identified issues * chore: adress reviews * chore: use the text component from @deriv-com/ui * chore: change alignment * chore: update color based on the textarea status * chore: seperate component into sub-components * chore: rename file * chore: add tsdoc * refactor: extract reducer into its own file * chore: remove redandunt css attribute * chore: rename component to a more meaningful name * refactor: move form and header components to components folder * refactor: drop provider pattern * chore: change name to a shorter one * chore: add tsdoc and update names and folders * refactor: combine modals into one * chore: address comments * chore: update object property * chore: remove duplicate modal * chore: extract footer component and address review comments * chore: address code reviews * chore: use button instead of text * chore: address sonarcloud * chore: use input from @deriv-com/ui
- Loading branch information
Showing
75 changed files
with
1,552 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
// TODO: Delete this component once @deriv-com/ui has it published | ||
|
||
export { default as Dropdown } from './Dropdown'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.p2p-v2-flyout-menu { | ||
&__list { | ||
position: absolute; | ||
top: 4.8rem; | ||
right: 0; | ||
min-width: 12.8rem; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
z-index: 2; | ||
border-radius: 0.4rem; | ||
background: #fff; | ||
box-shadow: 0 3.2rem 6.4rem 0 rgba(14, 14, 14, 0.14); | ||
overflow-y: auto; | ||
& > li { | ||
width: 100%; | ||
& > * { | ||
padding: 1rem 1.6rem; | ||
width: 100%; | ||
display: inline-block; | ||
& > * { | ||
color: #0e0e0e; | ||
font-weight: 400; | ||
} | ||
&:hover { | ||
cursor: pointer; | ||
background-color: #e6e9e9; | ||
& > * { | ||
text-decoration: none; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { HTMLAttributes, ReactNode, useRef, useState } from 'react'; | ||
import { useOnClickOutside } from 'usehooks-ts'; | ||
import FlyoutMenuList from './FlyoutMenuList'; | ||
import FlyoutMenuToggle from './FlyoutMenuToggle'; | ||
import './FlyoutMenu.scss'; | ||
|
||
type TFlyoutMenuProps = HTMLAttributes<HTMLDivElement> & { | ||
listItems?: ReactNode[]; | ||
renderIcon?: () => React.ReactNode; | ||
}; | ||
|
||
const FlyoutMenu = ({ listItems, renderIcon, ...props }: TFlyoutMenuProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const flyoutMenuRef = useRef<HTMLDivElement>(null); | ||
useOnClickOutside(flyoutMenuRef, () => setIsOpen(false)); | ||
return ( | ||
<div ref={flyoutMenuRef} {...props}> | ||
<FlyoutMenuToggle onClick={() => setIsOpen(!isOpen)} renderIcon={renderIcon} /> | ||
<FlyoutMenuList isOpen={isOpen} listItems={listItems} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FlyoutMenu; |
18 changes: 18 additions & 0 deletions
18
packages/p2p-v2/src/components/FlyoutMenu/FlyoutMenuList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { isValidElement, ReactNode } from 'react'; | ||
|
||
type TFlyoutListProps = { | ||
isOpen?: boolean; | ||
listItems?: ReactNode[]; | ||
}; | ||
|
||
const FlyoutList = ({ isOpen = false, listItems }: TFlyoutListProps) => { | ||
return isOpen ? ( | ||
<ul className='p2p-v2-flyout-menu__list'> | ||
{listItems?.map(listItem => { | ||
return <li key={isValidElement(listItem) ? listItem.key : listItem?.toString()}>{listItem}</li>; | ||
})} | ||
</ul> | ||
) : null; | ||
}; | ||
|
||
export default FlyoutList; |
11 changes: 11 additions & 0 deletions
11
packages/p2p-v2/src/components/FlyoutMenu/FlyoutMenuToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { HTMLAttributes, ReactNode } from 'react'; | ||
|
||
type TFlyoutToggleProps = HTMLAttributes<HTMLDivElement> & { | ||
renderIcon?: () => ReactNode; | ||
}; | ||
|
||
const FlyoutToggle = ({ renderIcon, ...props }: TFlyoutToggleProps) => { | ||
return <div {...props}>{renderIcon?.()}</div>; | ||
}; | ||
|
||
export default FlyoutToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as FlyoutMenu } from './FlyoutMenu'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...src/components/Modals/PaymentMethods/PaymentMethodErrorModal/PaymentMethodErrorModal.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.p2p-v2-payment-method-error-modal { | ||
&__wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 2.4rem; | ||
width: 44rem; | ||
@include mobile { | ||
width: 100%; | ||
} | ||
} | ||
&__buttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
width: 100%; | ||
&--cancel { | ||
background: transparent; | ||
border: 2px solid #999999; | ||
|
||
&:active:not([disabled]) { | ||
border: 1px solid #999999; | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../src/components/Modals/PaymentMethods/PaymentMethodErrorModal/PaymentMethodErrorModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useEffect } from 'react'; | ||
import ReactModal from 'react-modal'; | ||
import { Button } from '@deriv-com/ui/dist/components/Button'; | ||
import { Text } from '@deriv-com/ui/dist/components/Text'; | ||
import { customStyles } from '../../helpers'; | ||
import '../styles.scss'; | ||
import './PaymentMethodErrorModal.scss'; | ||
|
||
type TPaymentMethodErrorModalProps = { | ||
errorMessage: string; | ||
isModalOpen: boolean; | ||
onConfirm: () => void; | ||
title: string; | ||
}; | ||
|
||
const PaymentMethodErrorModal = ({ errorMessage, isModalOpen, onConfirm, title }: TPaymentMethodErrorModalProps) => { | ||
useEffect(() => { | ||
ReactModal.setAppElement('#v2_modal_root'); | ||
}, []); | ||
// TODO: Remember to translate these strings | ||
return ( | ||
<ReactModal | ||
className='p2p-v2-payment-method-modal__modal' | ||
contentLabel={title} | ||
isOpen={isModalOpen} | ||
shouldCloseOnOverlayClick={false} | ||
style={customStyles} | ||
> | ||
<div className='p2p-v2-payment-method-error-modal__wrapper'> | ||
<Text color='prominent' weight='bold'> | ||
{title} | ||
</Text> | ||
<Text color='prominent'>{errorMessage}</Text> | ||
<div className='p2p-v2-payment-method-error-modal__buttons'> | ||
<Button onClick={onConfirm} size='lg'> | ||
Ok | ||
</Button> | ||
</div> | ||
</div> | ||
</ReactModal> | ||
); | ||
}; | ||
|
||
export default PaymentMethodErrorModal; |
1 change: 1 addition & 0 deletions
1
packages/p2p-v2/src/components/Modals/PaymentMethods/PaymentMethodErrorModal/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as PaymentMethodErrorModal } from './PaymentMethodErrorModal'; |
71 changes: 71 additions & 0 deletions
71
...ges/p2p-v2/src/components/Modals/PaymentMethods/PaymentMethodModal/PaymentMethodModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { useEffect } from 'react'; | ||
import ReactModal from 'react-modal'; | ||
import { Button } from '@deriv-com/ui/dist/components/Button'; | ||
import { Text } from '@deriv-com/ui/dist/components/Text'; | ||
import { customStyles } from '../../helpers'; | ||
import '../styles.scss'; | ||
|
||
type TPaymentMethodModalProps = { | ||
description?: string; | ||
isModalOpen: boolean; | ||
onConfirm: () => void; | ||
onReject: () => void; | ||
primaryButtonLabel: string; | ||
secondaryButtonLabel: string; | ||
title?: string; | ||
}; | ||
|
||
const PaymentMethodModal = ({ | ||
description, | ||
isModalOpen, | ||
onConfirm, | ||
onReject, | ||
primaryButtonLabel, | ||
secondaryButtonLabel, | ||
title, | ||
}: TPaymentMethodModalProps) => { | ||
useEffect(() => { | ||
ReactModal.setAppElement('#v2_modal_root'); | ||
}, []); | ||
// TODO: Remember to translate these strings | ||
return ( | ||
<ReactModal | ||
className='p2p-v2-payment-method-modal__modal' | ||
contentLabel={title} | ||
isOpen={isModalOpen} | ||
shouldCloseOnOverlayClick={false} | ||
style={customStyles} | ||
> | ||
<div className='p2p-v2-payment-method-modal__wrapper'> | ||
<Text color='prominent' weight='bold'> | ||
{title} | ||
</Text> | ||
<Text color='prominent'>{description}</Text> | ||
<div className='p2p-v2-payment-method-modal__buttons'> | ||
<Button | ||
className='p2p-v2-payment-method-modal__buttons--cancel' | ||
onClick={e => { | ||
e.currentTarget.setAttribute('disabled', 'disabled'); | ||
onConfirm(); | ||
}} | ||
size='lg' | ||
variant='outlined' | ||
> | ||
{secondaryButtonLabel} | ||
</Button> | ||
<Button | ||
onClick={e => { | ||
e.currentTarget.setAttribute('disabled', 'disabled'); | ||
onReject(); | ||
}} | ||
size='lg' | ||
> | ||
{primaryButtonLabel} | ||
</Button> | ||
</div> | ||
</div> | ||
</ReactModal> | ||
); | ||
}; | ||
|
||
export default PaymentMethodModal; |
1 change: 1 addition & 0 deletions
1
packages/p2p-v2/src/components/Modals/PaymentMethods/PaymentMethodModal/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as PaymentMethodModal } from './PaymentMethodModal'; |
2 changes: 2 additions & 0 deletions
2
packages/p2p-v2/src/components/Modals/PaymentMethods/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './PaymentMethodErrorModal'; | ||
export * from './PaymentMethodModal'; |
40 changes: 40 additions & 0 deletions
40
packages/p2p-v2/src/components/Modals/PaymentMethods/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.p2p-v2-payment-method-modal { | ||
&__modal { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
right: auto; | ||
bottom: auto; | ||
margin-right: -50%; | ||
transform: translate(-50%, -50%); | ||
padding: 2.4rem; | ||
border-radius: 8px; | ||
background: #fff; | ||
box-shadow: 0px 32px 64px 0px rgba(14, 14, 14, 0.14); | ||
} | ||
&__wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-start; | ||
gap: 2.4rem; | ||
width: 44rem; | ||
@include mobile { | ||
width: 100%; | ||
} | ||
} | ||
&__buttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
gap: 1.6rem; | ||
width: 100%; | ||
&--cancel { | ||
background: transparent; | ||
border: 2px solid #999999; | ||
|
||
&:active:not([disabled]) { | ||
border: 1px solid #999999; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PaymentMethods'; |
22 changes: 22 additions & 0 deletions
22
packages/p2p-v2/src/components/PaymentMethodCard/PaymentMethodCard.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.p2p-v2-payment-method-card { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 67.2rem; | ||
border: 1px solid #d6dadb; | ||
border-radius: 8px; | ||
margin: 1.6rem 1.6rem 1.6rem 0; | ||
overflow-wrap: break-word; | ||
min-height: 12.8rem; | ||
padding: 1.6rem; | ||
width: 20.8rem; | ||
@include mobile { | ||
margin-right: 0; | ||
} | ||
|
||
@include mobile { | ||
min-height: 8.8rem; | ||
padding: 0.9rem 1rem; | ||
width: 15.4rem; | ||
} | ||
} |
Oops, something went wrong.
1708a7e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
deriv-app – ./
deriv-app.binary.sx
deriv-app-git-master.binary.sx
binary.sx
deriv-app.vercel.app