-
Notifications
You must be signed in to change notification settings - Fork 667
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
feat: add buy with crypto button to ENS detail page #2198
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6fb58a8
feat: add buy with crypto button to ENS detail page
juanmahidalgo 9a9ad6d
feat: remove buy page and add tests for the actions component
juanmahidalgo 9acb8c4
fix: eslint issue
juanmahidalgo c7df52b
fix: eslint issue
juanmahidalgo 2c1b228
feat: add isPartOfEstate logic to DetailsBox
juanmahidalgo 7d0b72b
feat: add estateInfo styles
juanmahidalgo c7f8bdb
feat: remove estate logic from details
juanmahidalgo 0aae7fe
test: fix test
juanmahidalgo 58d88a4
chore: eslint fixes
juanmahidalgo 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
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.
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.
If we're removing this, we should remove the
estateInfo
css as well, would you mind removing it?