Commit a3a32f0d authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: add null check to collection floor price (#4528)

* add null check to collection floor price

* don't show 0 if floor is null

* formatEthPrice accepts udnefined
Co-authored-by: default avatarCharlie <charlie@uniswap.org>
parent ee001f86
...@@ -141,7 +141,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }: ...@@ -141,7 +141,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
return { return {
...collection, ...collection,
collectionAddress: collection.address, collectionAddress: collection.address,
floorPrice: formatEthPrice(collection.floor.toString()), floorPrice: formatEthPrice(collection.floor?.toString()),
stats: { stats: {
total_supply: collection.totalSupply, total_supply: collection.totalSupply,
one_day_change: collection.floorChange, one_day_change: collection.floorChange,
......
...@@ -78,14 +78,14 @@ export const CollectionRow = ({ collection, isHovered, setHoveredIndex, toggleOp ...@@ -78,14 +78,14 @@ export const CollectionRow = ({ collection, isHovered, setHoveredIndex, toggleOp
<Box className={styles.secondaryText}>{putCommas(collection.stats.total_supply)} items</Box> <Box className={styles.secondaryText}>{putCommas(collection.stats.total_supply)} items</Box>
</Column> </Column>
</Row> </Row>
{collection.floorPrice && ( {collection.floorPrice ? (
<Column className={styles.suggestionSecondaryContainer}> <Column className={styles.suggestionSecondaryContainer}>
<Row gap="4"> <Row gap="4">
<Box className={styles.primaryText}>{ethNumberStandardFormatter(collection.floorPrice)} ETH</Box> <Box className={styles.primaryText}>{ethNumberStandardFormatter(collection.floorPrice)} ETH</Box>
</Row> </Row>
<Box className={styles.secondaryText}>Floor</Box> <Box className={styles.secondaryText}>Floor</Box>
</Column> </Column>
)} ) : null}
</Link> </Link>
) )
} }
......
...@@ -16,7 +16,7 @@ export const formatUSDPriceWithCommas = (price: number) => { ...@@ -16,7 +16,7 @@ export const formatUSDPriceWithCommas = (price: number) => {
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}` .replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
} }
export const formatEthPrice = (price: string) => { export const formatEthPrice = (price: string | undefined) => {
if (!price) return 0 if (!price) return 0
const formattedPrice = parseFloat(formatEther(String(price))) const formattedPrice = parseFloat(formatEther(String(price)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment