forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nada/feq 1392/advert list (deriv-com#13326)
* feat: advert list * fix: eslint errors * fix: fix styling issues * fix: test fix * fix: remove unused variables * fix: sonar issues * fix: replace regex * fix: prettier * fix: coveralls * fix: test fixes, removed unused variables, functions * fix: pr comments * fix: pr comments fix * fix: pr comments fixed
- Loading branch information
1 parent
54d4fe9
commit 1779ab7
Showing
54 changed files
with
1,793 additions
and
37 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
32 changes: 32 additions & 0 deletions
32
packages/p2p-v2/src/components/PopoverDropdown/PopoverDropdown.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,32 @@ | ||
.p2p-v2-popover-dropdown { | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
|
||
&__icon { | ||
margin-left: 1rem; | ||
} | ||
|
||
&__list { | ||
display: flex; | ||
flex-direction: column; | ||
border-radius: 0.4rem; | ||
width: 19.5rem; | ||
box-shadow: 0px 32px 64px 0px #0e0e0e24; | ||
z-index: 999; | ||
top: 2.8rem; | ||
position: absolute; | ||
background: #fff; | ||
right: 0; | ||
|
||
.derivs-button__color--primary:hover:not(:disabled) { | ||
background-color: var(--general-hover); | ||
} | ||
|
||
&-item { | ||
padding: 1rem 1.6rem; | ||
background-color: inherit; | ||
height: inherit; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/p2p-v2/src/components/PopoverDropdown/PopoverDropdown.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,50 @@ | ||
import React, { useRef, useState } from 'react'; | ||
import { Button, Text } from '@deriv-com/ui'; | ||
import { useOnClickOutside } from 'usehooks-ts'; | ||
import { LabelPairedEllipsisVerticalMdRegularIcon } from '@deriv/quill-icons'; | ||
import './PopoverDropdown.scss'; | ||
|
||
type TItem = { | ||
label: string; | ||
value: string; | ||
}; | ||
|
||
type TPopoverDropdownProps = { | ||
dataTestId?: string; | ||
dropdownList: TItem[]; | ||
onClick: (value: string) => void; | ||
}; | ||
|
||
const PopoverDropdown = ({ dataTestId, dropdownList, onClick }: TPopoverDropdownProps) => { | ||
const [visible, setVisible] = useState(false); | ||
const ref = useRef(null); | ||
useOnClickOutside(ref, () => setVisible(false)); | ||
|
||
return ( | ||
<div className='p2p-v2-popover-dropdown' ref={ref}> | ||
<LabelPairedEllipsisVerticalMdRegularIcon | ||
className='p2p-v2-popover-dropdown__icon' | ||
data-testid={dataTestId} | ||
onClick={() => setVisible(prevState => !prevState)} | ||
/> | ||
{visible && ( | ||
<div className='p2p-v2-popover-dropdown__list'> | ||
{dropdownList.map(item => ( | ||
<Button | ||
className='p2p-v2-popover-dropdown__list-item' | ||
key={item.value} | ||
onClick={() => { | ||
onClick(item.value); | ||
setVisible(false); | ||
}} | ||
> | ||
<Text key={item.value}>{item.label}</Text> | ||
</Button> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default PopoverDropdown; |
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 PopoverDropdown } from './PopoverDropdown'; |
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,22 @@ | ||
export const COUNTERPARTIES_DROPDOWN_LIST = [ | ||
{ value: 'all', text: 'All' }, | ||
{ value: 'blocked', text: 'Blocked' }, | ||
]; | ||
|
||
export const RATE_TYPE = { | ||
FLOAT: 'float', | ||
FIXED: 'fixed', | ||
}; | ||
|
||
export const AD_ACTION = { | ||
EDIT: 'edit', | ||
CREATE: 'create', | ||
ACTIVATE: 'activate', | ||
DEACTIVATE: 'deactivate', | ||
DELETE: 'delete', | ||
}; | ||
|
||
export const ADVERT_TYPE = { | ||
SELL: 'Sell', | ||
BUY: 'Buy', | ||
}; |
This file was deleted.
Oops, something went wrong.
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,3 +1,3 @@ | ||
export * from './counterparties-dropdown'; | ||
export * from './ad-constants'; | ||
export * from './payment-methods'; | ||
export * from './validation'; |
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,2 @@ | ||
export * from './my-ads'; | ||
export * from './my-profile'; |
38 changes: 38 additions & 0 deletions
38
packages/p2p-v2/src/pages/my-ads/components/AdStatus/AdStatus.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,38 @@ | ||
@mixin ad-status-base($background-color) { | ||
&:before { | ||
content: ''; | ||
height: 100%; | ||
width: 100%; | ||
opacity: 0.16; | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
border-radius: 1.6rem; | ||
background-color: $background-color; | ||
} | ||
align-items: center; | ||
display: flex; | ||
justify-content: center; | ||
padding: 0.1rem 1.2rem; | ||
position: relative; | ||
} | ||
|
||
.p2p-v2-ad-status { | ||
&--active { | ||
@include ad-status-base(var(--status-success)); | ||
|
||
width: fit-content; | ||
|
||
@include mobile { | ||
margin-bottom: 0.8rem; | ||
padding: 0.2rem 1rem; | ||
} | ||
} | ||
|
||
&--inactive { | ||
@include ad-status-base(var(--status-danger)); | ||
|
||
width: fit-content; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/p2p-v2/src/pages/my-ads/components/AdStatus/AdStatus.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,29 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import { Text } from '@deriv-com/ui'; | ||
import { useDevice } from '@/hooks'; | ||
import './AdStatus.scss'; | ||
|
||
type TAdStatusProps = { | ||
isActive?: boolean; | ||
}; | ||
|
||
const AdStatus = ({ isActive = false }: TAdStatusProps) => { | ||
const { isMobile } = useDevice(); | ||
return ( | ||
<Text | ||
align='center' | ||
className={clsx({ | ||
'p2p-v2-ad-status--active': isActive, | ||
'p2p-v2-ad-status--inactive': !isActive, | ||
})} | ||
color={isActive ? 'success' : 'error'} | ||
size={isMobile ? 'md' : 'sm'} | ||
weight='bold' | ||
> | ||
{isActive ? 'Active' : 'Inactive'} | ||
</Text> | ||
); | ||
}; | ||
|
||
export default AdStatus; |
14 changes: 14 additions & 0 deletions
14
packages/p2p-v2/src/pages/my-ads/components/AdStatus/__tests__/AdStatus.spec.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,14 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import AdStatus from '../AdStatus'; | ||
|
||
describe('AdStatus', () => { | ||
it('should render the component as expected with Inactive as default', () => { | ||
render(<AdStatus />); | ||
expect(screen.getByText('Inactive')).toBeInTheDocument(); | ||
}); | ||
it('should render active when isActive is true', () => { | ||
render(<AdStatus isActive={true} />); | ||
expect(screen.getByText('Active')).toBeInTheDocument(); | ||
}); | ||
}); |
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 AdStatus } from './AdStatus'; |
Oops, something went wrong.