-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ameerul / P2PS-4363 Banner on Buy/Sell page #401
Open
ameerul-deriv
wants to merge
12
commits into
deriv-com:master
Choose a base branch
from
ameerul-deriv:P2PS-4363-banner-on-buy-sell-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1695fa2
chore: added Funds Banner and Modal
ameerul-deriv bfc0ea4
chore: added test cases for FundsBanner and FundsModal
ameerul-deriv 59a0be6
fix: show Banner in Buy/Sell page only
ameerul-deriv 6ce829e
chore: show banner if user is an advertiser
ameerul-deriv f122deb
fix: dont hide the banner if FundsModal isShowing
ameerul-deriv 7464cc4
chore: fix BuySellheader failing test cases
ameerul-deriv 6ecd646
chore: removed important and targeted header
ameerul-deriv 816426e
chore: fix position of p2p guide icon
ameerul-deriv bd0c708
fix: guide icon position for non advertisers
ameerul-deriv b10b72d
fix: merge conflicts
ameerul-deriv 2760fd7
chore: added logic to check if user has migrated to wallets
ameerul-deriv d030c3d
fix: hide cashier tab if user has migrated to wallets
ameerul-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.funds-banner { | ||
@include mobile-or-tablet-screen { | ||
padding: 1.6rem 1.6rem 0.8rem; | ||
} | ||
|
||
&__inline-message { | ||
background-color: rgba(44, 154, 255, 0.08); | ||
border-radius: 1.6rem; | ||
padding: 1.6rem; | ||
margin-bottom: 1.5rem; | ||
|
||
@include mobile-or-tablet-screen { | ||
margin-bottom: 0; | ||
} | ||
|
||
&__button { | ||
padding: 0; | ||
text-decoration: underline; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: transparent !important; | ||
|
||
& > span { | ||
color: #0e0e0e !important; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.deriv-inline-message__icon { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
} |
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,41 @@ | ||
import { FundsModal } from '@/components/Modals'; | ||
import { useModalManager } from '@/hooks/custom-hooks'; | ||
import { LabelPairedCircleInfoLgBoldIcon } from '@deriv/quill-icons'; | ||
import { Localize } from '@deriv-com/translations'; | ||
import { Button, InlineMessage, Text, useDevice } from '@deriv-com/ui'; | ||
import './FundsBanner.scss'; | ||
|
||
const FundsBanner = () => { | ||
const { isDesktop } = useDevice(); | ||
const { hideModal, isModalOpenFor, showModal } = useModalManager(); | ||
const textSize = isDesktop ? 'sm' : 'md'; | ||
|
||
return ( | ||
<div className='funds-banner'> | ||
<InlineMessage | ||
className='funds-banner__inline-message' | ||
icon={<LabelPairedCircleInfoLgBoldIcon fill='#0777C4' height={24} width={24} />} | ||
iconPosition='center' | ||
> | ||
<div> | ||
<Text className='mr-1' size={textSize}> | ||
<Localize i18n_default_text='Your P2P funds are accessible through your Options trading account.' /> | ||
</Text> | ||
<Button | ||
className='funds-banner__inline-message__button' | ||
color='black' | ||
hideHoverStyles | ||
onClick={() => showModal('FundsModal')} | ||
textSize={textSize} | ||
variant='ghost' | ||
> | ||
<Localize i18n_default_text='Learn more' /> | ||
</Button> | ||
</div> | ||
</InlineMessage> | ||
{!!isModalOpenFor('FundsModal') && <FundsModal isModalOpen onRequestClose={hideModal} />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FundsBanner; |
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,61 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import FundsBanner from '../FundsBanner'; | ||
|
||
const mockModalManager = { | ||
hideModal: jest.fn(), | ||
isModalOpenFor: jest.fn().mockReturnValue(false), | ||
showModal: jest.fn(), | ||
}; | ||
|
||
jest.mock('@deriv-com/ui', () => ({ | ||
...jest.requireActual('@deriv-com/ui'), | ||
useDevice: jest.fn().mockReturnValue({ | ||
isMobile: false, | ||
}), | ||
})); | ||
|
||
jest.mock('@/hooks/custom-hooks', () => ({ | ||
useModalManager: jest.fn(() => mockModalManager), | ||
})); | ||
|
||
describe('<FundsBanner />', () => { | ||
it('should render the FundsBanner', () => { | ||
render(<FundsBanner />); | ||
|
||
expect( | ||
screen.getByText(/Your P2P funds are accessible through your Options trading account./) | ||
).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: /Learn more/ })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call showModal when the Learn more button is clicked and show the FundsModal', () => { | ||
render(<FundsBanner />); | ||
fireEvent.click(screen.getByRole('button', { name: /Learn more/ })); | ||
|
||
expect(mockModalManager.showModal).toHaveBeenCalledWith('FundsModal'); | ||
}); | ||
|
||
it('should render the FundsModal if it is open', () => { | ||
mockModalManager.isModalOpenFor.mockImplementation((modalName: string) => modalName === 'FundsModal'); | ||
render(<FundsBanner />); | ||
|
||
expect(screen.getByText('How to fund your trades?')).toBeInTheDocument(); | ||
expect(screen.getByText('For Options trading:')).toBeInTheDocument(); | ||
expect(screen.getByText('Trade directly with funds from your Options trading account.')).toBeInTheDocument(); | ||
expect(screen.getByText('For CFDs trading:')).toBeInTheDocument(); | ||
expect( | ||
screen.getByText('1. Transfer funds from your Options trading account to your USD Wallet.') | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText('2. Then, move the funds from your USD Wallet to your CFDs account.') | ||
).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call hideModal when the OK button is clicked', () => { | ||
render(<FundsBanner />); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: 'OK' })); | ||
expect(mockModalManager.hideModal).toHaveBeenCalled(); | ||
}); | ||
}); |
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 FundsBanner } from './FundsBanner'; |
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,31 @@ | ||
.funds-modal { | ||
@include default-modal; | ||
.deriv-modal__header { | ||
padding-top: 1rem; | ||
|
||
@include mobile-or-tablet-screen { | ||
padding-top: 0 !important; | ||
padding-left: 1.6rem; | ||
} | ||
} | ||
|
||
&__body { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1rem 2.4rem; | ||
gap: 2.4rem; | ||
|
||
@include mobile-or-tablet-screen { | ||
padding: 0 1.6rem; | ||
} | ||
} | ||
|
||
&__footer { | ||
padding-bottom: 2.4rem; | ||
gap: 0.8rem; | ||
|
||
@include mobile-or-tablet-screen { | ||
padding: 1.6rem; | ||
} | ||
} | ||
} |
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,48 @@ | ||
import { Localize } from '@deriv-com/translations'; | ||
import { Button, Modal, Text } from '@deriv-com/ui'; | ||
import './FundsModal.scss'; | ||
|
||
type TFundsModalProps = { | ||
isModalOpen: boolean; | ||
onRequestClose: () => void; | ||
}; | ||
|
||
const FundsModal = ({ isModalOpen, onRequestClose }: TFundsModalProps) => { | ||
return ( | ||
<Modal ariaHideApp={false} className='funds-modal' isOpen={isModalOpen} shouldCloseOnOverlayClick={false}> | ||
<Modal.Header hideBorder hideCloseIcon> | ||
<Text size='md' weight='bold'> | ||
<Localize i18n_default_text='How to fund your trades?' /> | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body className='funds-modal__body'> | ||
<div className='flex flex-col'> | ||
<Text size='sm' weight='bold'> | ||
<Localize i18n_default_text='For Options trading:' /> | ||
</Text> | ||
<Text size='sm'> | ||
<Localize i18n_default_text='Trade directly with funds from your Options trading account.' /> | ||
</Text> | ||
</div> | ||
<div className='flex flex-col'> | ||
<Text size='sm' weight='bold'> | ||
<Localize i18n_default_text='For CFDs trading:' /> | ||
</Text> | ||
<Text size='sm'> | ||
<Localize i18n_default_text='1. Transfer funds from your Options trading account to your USD Wallet.' /> | ||
</Text> | ||
<Text size='sm'> | ||
<Localize i18n_default_text='2. Then, move the funds from your USD Wallet to your CFDs account.' /> | ||
</Text> | ||
</div> | ||
</Modal.Body> | ||
<Modal.Footer className='funds-modal__footer' hideBorder> | ||
<Button onClick={() => onRequestClose()} size='lg' textSize='sm'> | ||
<Localize i18n_default_text='OK' /> | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default FundsModal; |
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 FundsModal } from './FundsModal'; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
even though I used hideHoverStyles in the button, it didn't work 😅 so i had to manually disable it here