fix: only disable erc 1155 in sell mode (#5183)

* init

* make height into variable

* respond charlie

* cleaner code

* dont include erc 1155 when selecting all

* fix

* disable select all for sus flag nfts too

* oops
This commit is contained in:
lynn 2022-11-12 00:03:19 -05:00 committed by GitHub
parent 935694630b
commit 66bdfd8a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 53 deletions

@ -15,7 +15,7 @@ import {
import { body, bodySmall, buttonTextSmall, subhead, subheadSmall } from 'nft/css/common.css'
import { themeVars } from 'nft/css/sprinkles.css'
import { useIsMobile } from 'nft/hooks'
import { GenieAsset, Rarity, UniformHeight, UniformHeights, WalletAsset } from 'nft/types'
import { GenieAsset, Rarity, TokenType, UniformHeight, UniformHeights, WalletAsset } from 'nft/types'
import { isAudio, isVideo } from 'nft/utils'
import { fallbackProvider, putCommas } from 'nft/utils'
import { floorFormatter } from 'nft/utils/numbers'
@ -530,6 +530,12 @@ const ProfileNftDetails = ({ asset, isSellMode }: ProfileNftDetailsProps) => {
return !!asset.name ? asset.name : `#${asset.tokenId}`
}
const shouldShowUserListedPrice =
!!asset.floor_sell_order_price &&
!asset.notForSale &&
(asset.asset_contract.tokenType !== TokenType.ERC1155 || isSellMode)
const shouldShowFloorPrice = asset.notForSale && isSellMode && !!asset.floorPrice
return (
<Box overflow="hidden" width="full" flexWrap="nowrap">
<Row justifyItems="flex-start">
@ -549,15 +555,16 @@ const ProfileNftDetails = ({ asset, isSellMode }: ProfileNftDetailsProps) => {
</TruncatedTextRow>
{asset.susFlag && <Suspicious />}
</Row>
<TruncatedTextRow
className={subhead}
style={{ color: !asset.notForSale ? themeVars.colors.textPrimary : themeVars.colors.textSecondary }}
>
{!asset.notForSale && <span>{`${floorFormatter(asset.floor_sell_order_price)} ETH`}</span>}
{asset.notForSale && isSellMode && !!asset.floorPrice && (
<span>{`${floorFormatter(asset.floorPrice)} ETH Floor`}</span>
)}
</TruncatedTextRow>
{shouldShowUserListedPrice && (
<TruncatedTextRow className={subhead} style={{ color: themeVars.colors.textPrimary }}>
{`${floorFormatter(asset.floor_sell_order_price)} ETH`}
</TruncatedTextRow>
)}
{shouldShowFloorPrice && (
<TruncatedTextRow className={subhead} style={{ color: themeVars.colors.textSecondary }}>
{`${floorFormatter(asset.floorPrice)} ETH Floor`}
</TruncatedTextRow>
)}
</Box>
)
}

@ -2,6 +2,7 @@ import { Box } from 'nft/components/Box'
import { Column, Row } from 'nft/components/Flex'
import { useIsMobile } from 'nft/hooks'
import { CollectionBannerLoading } from 'nft/pages/collection'
import { COLLECTION_BANNER_HEIGHT } from 'nft/pages/collection'
import { ActivitySwitcherLoading } from './ActivitySwitcher'
import { CollectionNftsAndMenuLoading } from './CollectionNfts'
@ -11,7 +12,7 @@ export const CollectionPageSkeleton = () => {
const isMobile = useIsMobile()
return (
<Column width="full">
<Box width="full" height="160">
<Box width="full" height={`${COLLECTION_BANNER_HEIGHT}`}>
<CollectionBannerLoading />
</Box>
<Column paddingX="32">

@ -20,6 +20,7 @@ import {
} from 'nft/hooks'
import { ScreenBreakpointsPaddings } from 'nft/pages/collection/index.css'
import { OSCollectionsFetcher } from 'nft/queries'
import { TokenType } from 'nft/types'
import { UniformHeight, UniformHeights } from 'nft/types'
import { ProfilePageStateType, WalletAsset, WalletCollection } from 'nft/types'
import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react'
@ -245,7 +246,9 @@ const SelectAllButton = ({ ownerAssets }: { ownerAssets: WalletAsset[] }) => {
useEffect(() => {
if (isAllSelected) {
ownerAssets.forEach((asset) => selectSellAsset(asset))
ownerAssets.forEach(
(asset) => asset.asset_contract.tokenType !== TokenType.ERC1155 && !asset.susFlag && selectSellAsset(asset)
)
} else {
resetSellAssets()
}

@ -6,7 +6,7 @@ import { AssetMediaType } from 'nft/components/collection/Card'
import { bodySmall } from 'nft/css/common.css'
import { themeVars } from 'nft/css/sprinkles.css'
import { useBag, useIsMobile, useSellAsset } from 'nft/hooks'
import { WalletAsset } from 'nft/types'
import { TokenType, WalletAsset } from 'nft/types'
import { UniformHeight } from 'nft/types'
import { useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
@ -93,30 +93,30 @@ export const ViewMyNftsAsset = ({
const assetMediaType = Card.useAssetMediaType(asset)
const isDisabled = asset.asset_contract.tokenType === 'ERC1155' || (isSellMode && asset.susFlag)
const isDisabled = isSellMode && (asset.asset_contract.tokenType === TokenType.ERC1155 || asset.susFlag)
const disabledTooltipText =
asset.asset_contract.tokenType === 'ERC1155' ? 'ERC-1155 support coming soon' : 'Blocked from trading'
asset.asset_contract.tokenType === TokenType.ERC1155 ? 'ERC-1155 support coming soon' : 'Blocked from trading'
return (
<Card.Container
asset={asset}
selected={isSelected}
addAssetToBag={() => handleSelect(false)}
removeAssetFromBag={() => handleSelect(true)}
onClick={onCardClick}
isDisabled={isDisabled}
<MouseoverTooltip
text={
<Box as="span" className={bodySmall} style={{ color: themeVars.colors.textPrimary }}>
<Trans>{disabledTooltipText}</Trans>{' '}
</Box>
}
placement="bottom"
offsetX={0}
offsetY={-180}
style={{ display: 'block' }}
disableHover={!isDisabled}
>
<MouseoverTooltip
text={
<Box as="span" className={bodySmall} style={{ color: themeVars.colors.textPrimary }}>
<Trans>{disabledTooltipText}</Trans>{' '}
</Box>
}
placement="bottom"
offsetX={0}
offsetY={-100}
style={{ display: 'block' }}
disableHover={!isDisabled}
<Card.Container
asset={asset}
selected={isSelected}
addAssetToBag={() => handleSelect(false)}
removeAssetFromBag={() => handleSelect(true)}
onClick={onCardClick}
isDisabled={isDisabled}
>
<Card.ImageContainer>
{getNftDisplayComponent(
@ -127,10 +127,10 @@ export const ViewMyNftsAsset = ({
setUniformHeight
)}
</Card.ImageContainer>
</MouseoverTooltip>
<Card.DetailsContainer>
<Card.ProfileNftDetails asset={asset} isSellMode={isSellMode} />
</Card.DetailsContainer>
</Card.Container>
<Card.DetailsContainer>
<Card.ProfileNftDetails asset={asset} isSellMode={isSellMode} />
</Card.DetailsContainer>
</Card.Container>
</MouseoverTooltip>
)
}

@ -21,6 +21,7 @@ import { ThemedText } from 'theme'
const FILTER_WIDTH = 332
const BAG_WIDTH = 324
export const COLLECTION_BANNER_HEIGHT = 276
export const CollectionBannerLoading = () => <Box height="full" width="full" className={styles.loadingBanner} />
@ -113,21 +114,19 @@ const Collection = () => {
{contractAddress ? (
<>
{' '}
<Box width="full" height="276">
<Box width="full" height="276">
<Box
as={collectionStats?.bannerImageUrl ? 'img' : 'div'}
height="full"
width="full"
src={
collectionStats?.bannerImageUrl
? `${collectionStats.bannerImageUrl}?w=${window.innerWidth}`
: undefined
}
className={styles.bannerImage}
background="none"
/>
</Box>
<Box width="full" height={`${COLLECTION_BANNER_HEIGHT}`}>
<Box
as={collectionStats?.bannerImageUrl ? 'img' : 'div'}
height="full"
width="full"
src={
collectionStats?.bannerImageUrl
? `${collectionStats.bannerImageUrl}?w=${window.innerWidth}`
: undefined
}
className={styles.bannerImage}
background="none"
/>
</Box>
<CollectionDescriptionSection>
{collectionStats && (