-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add buy with crypto button to ENS detail page (#2198)
* feat: add buy with crypto button to ENS detail page * feat: remove buy page and add tests for the actions component * fix: eslint issue * fix: eslint issue * feat: add isPartOfEstate logic to DetailsBox * feat: add estateInfo styles * feat: remove estate logic from details * test: fix test * chore: eslint fixes
- Loading branch information
1 parent
f89cdcc
commit d145fe8
Showing
16 changed files
with
138 additions
and
201 deletions.
There are no files selected for viewing
14 changes: 11 additions & 3 deletions
14
webapp/src/components/AssetPage/Actions/Actions.container.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import { connect } from 'react-redux' | ||
import { Order } from '@dcl/schemas' | ||
import { openModal } from 'decentraland-dapps/dist/modules/modal/actions' | ||
import { NFT } from '../../../modules/nft/types' | ||
import { getCurrentOrder } from '../../../modules/order/selectors' | ||
import { RootState } from '../../../modules/reducer' | ||
import { getNFTBids } from '../../../modules/ui/nft/bid/selectors' | ||
import { getWallet } from '../../../modules/wallet/selectors' | ||
import Actions from './Actions' | ||
import { MapDispatch, MapDispatchProps, MapStateProps } from './Actions.types' | ||
import { MapDispatch, MapDispatchProps, MapStateProps, OwnProps } from './Actions.types' | ||
|
||
const mapState = (state: RootState): MapStateProps => ({ | ||
wallet: getWallet(state), | ||
order: getCurrentOrder(state), | ||
bids: getNFTBids(state) | ||
}) | ||
|
||
const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ | ||
onLeavingSite: (nft: NFT) => dispatch(openModal('LeavingSiteModal', { nft })) | ||
const mapDispatch = (dispatch: MapDispatch, ownProps: OwnProps): MapDispatchProps => ({ | ||
onLeavingSite: (nft: NFT) => dispatch(openModal('LeavingSiteModal', { nft })), | ||
onBuyWithCrypto: (order: Order) => | ||
dispatch( | ||
openModal('BuyNftWithCryptoModal', { | ||
nft: ownProps.nft, | ||
order | ||
}) | ||
) | ||
}) | ||
|
||
export default connect(mapState, mapDispatch)(Actions) |
115 changes: 115 additions & 0 deletions
115
webapp/src/components/AssetPage/Actions/Actions.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,115 @@ | ||
import { Bid, Order } from '@dcl/schemas' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Wallet } from 'decentraland-dapps/dist/modules/wallet' | ||
import { NFT } from '../../../modules/nft/types' | ||
import { VendorName } from '../../../modules/vendor' | ||
import { renderWithProviders } from '../../../utils/test' | ||
import Actions from './Actions' | ||
import { Props } from './Actions.types' | ||
|
||
describe('Actions Component', () => { | ||
let props: Props | ||
let nft: NFT | ||
let wallet: Wallet | ||
let order: Order | null | ||
let bids: Bid[] | ||
let onBuyWithCrypto: (order: Order) => void | ||
let onLeavingSite | ||
let address: string | ||
|
||
beforeEach(() => { | ||
address = '0xAnAddress' | ||
wallet = { address: 'user-wallet-address' } as Wallet | ||
nft = { | ||
contractAddress: 'nft-contract-address', | ||
tokenId: 'nft-token-id', | ||
vendor: VendorName.DECENTRALAND, | ||
data: {} | ||
} as NFT | ||
// order = null | ||
bids = [] | ||
onBuyWithCrypto = jest.fn() | ||
onLeavingSite = jest.fn() | ||
props = { | ||
wallet, | ||
nft, | ||
order, | ||
bids, | ||
onBuyWithCrypto, | ||
onLeavingSite | ||
} | ||
}) | ||
|
||
describe('and it has an order', () => { | ||
beforeEach(() => { | ||
order = {} as Order | ||
}) | ||
describe('and it is owner and can sell', () => { | ||
beforeEach(() => { | ||
nft.owner = address | ||
wallet.address = nft.owner | ||
}) | ||
it('should render the update and the cancel sale button', () => { | ||
const { queryByText } = renderWithProviders(<Actions {...props} order={order} />) | ||
const updateButton = queryByText(t('asset_page.actions.update')) | ||
const cancelButton = queryByText(t('asset_page.actions.cancel_sale')) | ||
expect(updateButton).toBeInTheDocument() | ||
expect(cancelButton).toBeInTheDocument() | ||
}) | ||
}) | ||
describe('and its not the owner', () => { | ||
beforeEach(() => { | ||
nft.owner = '0xAnotherAddress' | ||
wallet.address = address | ||
}) | ||
it('should render the bid button and not render the update and the cancel sale button', () => { | ||
const { queryByText } = renderWithProviders(<Actions {...props} order={order} />) | ||
const bidButton = queryByText(t('asset_page.actions.bid')) | ||
const updateButton = queryByText(t('asset_page.actions.update')) | ||
const cancelButton = queryByText(t('asset_page.actions.cancel_sale')) | ||
expect(bidButton).toBeInTheDocument() | ||
expect(updateButton).not.toBeInTheDocument() | ||
expect(cancelButton).not.toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
describe('and there is no order', () => { | ||
beforeEach(() => { | ||
order = null | ||
}) | ||
describe('and its the owner', () => { | ||
beforeEach(() => { | ||
nft.owner = address | ||
wallet.address = nft.owner | ||
}) | ||
describe('and its an ENS name', () => { | ||
beforeEach(() => { | ||
nft.data.ens = { subdomain: '' } | ||
}) | ||
it('should render the manage button', () => { | ||
const { queryByText } = renderWithProviders(<Actions {...props} order={order} />) | ||
const manageButton = queryByText(t('asset_page.actions.manage')) | ||
expect(manageButton).toBeInTheDocument() | ||
}) | ||
}) | ||
it('should render the sell and transfer button', () => { | ||
const { queryByText } = renderWithProviders(<Actions {...props} order={order} />) | ||
const sellButton = queryByText(t('asset_page.actions.sell')) | ||
const transferButton = queryByText(t('asset_page.actions.transfer')) | ||
expect(sellButton).toBeInTheDocument() | ||
expect(transferButton).toBeInTheDocument() | ||
}) | ||
}) | ||
describe('and it is not the owner', () => { | ||
beforeEach(() => { | ||
nft.owner = '0xAnotherAddress' | ||
wallet.address = address | ||
}) | ||
it('should render the bid button', () => { | ||
const { queryByText } = renderWithProviders(<Actions {...props} order={order} />) | ||
const bidButton = queryByText(t('asset_page.actions.bid')) | ||
expect(bidButton).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
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
9 changes: 0 additions & 9 deletions
9
webapp/src/components/AssetPage/ParcelDetail/ParcelDetail.module.css
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.