Skip to content

Commit

Permalink
Feat/l1 wearables (#1737)
Browse files Browse the repository at this point in the history
* feat: removed favorites and creator for items in ethereum

* fix: test

* fix: onback test
  • Loading branch information
flobarreto authored May 30, 2023
1 parent df8d9e1 commit cea9d85
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 21 deletions.
14 changes: 8 additions & 6 deletions webapp/src/components/AssetCard/AssetCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useMemo } from 'react'
import { Item, RentalListing } from '@dcl/schemas'
import { Item, Network, RentalListing } from '@dcl/schemas'
import { useInView } from 'react-intersection-observer'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { Profile } from 'decentraland-dapps/dist/containers'
Expand Down Expand Up @@ -217,11 +217,13 @@ const AssetCard = (props: Props) => {
className={isCatalogItem(asset) ? 'catalogTitle' : 'title'}
>
<span className={'textOverflow'}>{title}</span>
{!isNFT(asset) && isCatalogItem(asset) && (
<span className="creator">
<Profile address={asset.creator} textOnly />
</span>
)}
{!isNFT(asset) &&
isCatalogItem(asset) &&
asset.network === Network.MATIC && (
<span className="creator">
<Profile address={asset.creator} textOnly />
</span>
)}
</div>
{!isCatalogItem(asset) && price ? (
<Mana network={asset.network} inline>
Expand Down
51 changes: 42 additions & 9 deletions webapp/src/components/AssetPage/BuyNFTBox/BuyNFTBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const BuyNFTBox = ({ nft, address }: Props) => {
} | null>(null)

const [canBid, setCanBid] = useState(false)
const isOwner = nft && nft?.owner === address

useEffect(() => {
if (nft && nft?.owner !== address) {
if (!isOwner && nft) {
bidAPI
.fetchByNFT(
nft.contractAddress,
Expand All @@ -46,7 +47,7 @@ const BuyNFTBox = ({ nft, address }: Props) => {
console.error(error)
})
}
}, [nft, address])
}, [nft, address, isOwner])

useEffect(() => {
if (nft) {
Expand Down Expand Up @@ -116,13 +117,45 @@ const BuyNFTBox = ({ nft, address }: Props) => {
</div>
</div>
</div>
<BuyNFTButtons
assetType={AssetType.NFT}
contractAddress={nft.contractAddress}
network={nft.network}
tokenId={nft.tokenId}
buyWithCardClassName={styles.buyWithCardClassName}
/>
{isOwner ? (
listing ? (
<>
<Button
as={Link}
to={locations.sell(nft.contractAddress, nft.tokenId)}
primary
fluid
>
{t('asset_page.actions.update')}
</Button>
<Button
as={Link}
to={locations.cancel(nft.contractAddress, nft.tokenId)}
fluid
inverted
>
{t('asset_page.actions.cancel_sale')}
</Button>
</>
) : (
<Button
as={Link}
to={locations.sell(nft.contractAddress, nft.tokenId)}
primary
fluid
>
{t('asset_page.actions.sell')}
</Button>
)
) : (
<BuyNFTButtons
assetType={AssetType.NFT}
contractAddress={nft.contractAddress}
network={nft.network}
tokenId={nft.tokenId}
buyWithCardClassName={styles.buyWithCardClassName}
/>
)}
{canBid && (
<Button
inverted
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/AssetPage/ItemDetail/ItemDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo, useRef } from 'react'
import { BodyShape, EmotePlayMode, NFTCategory } from '@dcl/schemas'
import { BodyShape, EmotePlayMode, NFTCategory, Network } from '@dcl/schemas'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { locations } from '../../../modules/routing/locations'
import { Section } from '../../../modules/vendor/decentraland'
Expand Down Expand Up @@ -117,7 +117,7 @@ const ItemDetail = ({ item }: Props) => {
}
>
<div className={styles.basicRow}>
<Owner asset={item} />
{item.network === Network.MATIC ? <Owner asset={item} /> : null}
<Collection asset={item} />
</div>
<BestBuyingOption asset={item} tableRef={tableRef} />
Expand Down
7 changes: 6 additions & 1 deletion webapp/src/components/AssetPage/OnBack/OnBack.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMobileMediaQuery } from 'decentraland-ui/dist/components/Media'
import { Network } from '@dcl/schemas'
import { Asset } from '../../../modules/asset/types'
import { INITIAL_STATE } from '../../../modules/favorites/reducer'
import { renderWithProviders } from '../../../utils/test'
Expand Down Expand Up @@ -89,7 +90,11 @@ describe('OnBack', () => {

describe('and the asset is an item', () => {
beforeEach(() => {
asset = { ...asset, itemId: 'itemId' } as Asset
asset = {
...asset,
itemId: 'itemId',
network: Network.MATIC
} as Asset
useMobileMediaQueryMock.mockReturnValue(true)
})

Expand Down
6 changes: 5 additions & 1 deletion webapp/src/components/AssetPage/OnBack/OnBack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { Network } from '@dcl/schemas'
import { Button } from 'decentraland-ui'
import { useMobileMediaQuery } from 'decentraland-ui/dist/components/Media'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
Expand Down Expand Up @@ -74,7 +75,10 @@ const OnBack = ({ asset, isFavoritesEnabled, onBack }: Props) => {
<img src={onBackIcon} alt={t('global.back')} />
{t('global.back')}
</Button>
{isFavoritesEnabled && isMobile && !isNFT(asset) ? (
{isFavoritesEnabled &&
isMobile &&
!isNFT(asset) &&
asset.network === Network.MATIC ? (
<FavoritesCounter isCollapsed className="favorites" item={asset} />
) : null}
</div>
Expand Down
7 changes: 6 additions & 1 deletion webapp/src/components/AssetPage/Title/Title.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMobileMediaQuery } from 'decentraland-ui/dist/components/Media'
import { Network } from '@dcl/schemas'
import { Asset } from '../../../modules/asset/types'
import { getAssetName } from '../../../modules/asset/utils'
import { INITIAL_STATE } from '../../../modules/favorites/reducer'
Expand Down Expand Up @@ -91,7 +92,11 @@ describe('Title', () => {

describe('and the asset is an item', () => {
beforeEach(() => {
asset = { ...asset, itemId: 'itemId' } as Asset
asset = {
...asset,
itemId: 'itemId',
network: Network.MATIC
} as Asset
})

it('should render the favorites counter', () => {
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/components/AssetPage/Title/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { Network } from '@dcl/schemas'
import { useMobileMediaQuery } from 'decentraland-ui/dist/components/Media'
import { getAssetName, isNFT } from '../../../modules/asset/utils'
import { FavoritesCounter } from '../../FavoritesCounter'
Expand All @@ -14,7 +15,10 @@ const Title = ({ asset, isFavoritesEnabled }: Props) => {
{getAssetName(asset)} {isNFT(asset) ? `#${asset.issuedId}` : ''}{' '}
</span>
{/* TODO (lists): this may be moved after the new detail page for unified markets */}
{isFavoritesEnabled && !isMobile && !isNFT(asset) ? (
{isFavoritesEnabled &&
!isMobile &&
!isNFT(asset) &&
asset.network === Network.MATIC ? (
<FavoritesCounter
isCollapsed
className={styles.favorites}
Expand Down

0 comments on commit cea9d85

Please sign in to comment.