chore: remove extra decimals on cards (#4757)
* chore: removing decimals * only on cards * slight fix * updating across app
This commit is contained in:
parent
53f4fb9ede
commit
ed8aa08255
@ -110,7 +110,7 @@ export const CollectionAsset = ({
|
||||
<Card.SecondaryRow>
|
||||
<Card.SecondaryDetails>
|
||||
<Card.SecondaryInfo>
|
||||
{notForSale ? '' : `${formatWeiToDecimal(asset.currentEthPrice)} ETH`}
|
||||
{notForSale ? '' : `${formatWeiToDecimal(asset.currentEthPrice, true)} ETH`}
|
||||
</Card.SecondaryInfo>
|
||||
{(asset.marketplace === Markets.NFTX || asset.marketplace === Markets.NFT20) && <Card.Pool />}
|
||||
</Card.SecondaryDetails>
|
||||
|
@ -35,7 +35,7 @@ export const WithCommaCell = ({ value }: CellProps) => <span>{value.value ? putC
|
||||
|
||||
export const EthCell = ({ value }: { value: number }) => (
|
||||
<Row justifyContent="flex-end" color="textPrimary">
|
||||
{value ? <>{formatWeiToDecimal(value.toString())} ETH</> : '-'}
|
||||
{value ? <>{formatWeiToDecimal(value.toString(), true)} ETH</> : '-'}
|
||||
</Row>
|
||||
)
|
||||
|
||||
@ -66,7 +66,7 @@ export const EthWithDayChange = ({ value }: CellProps) => (
|
||||
export const WeiWithDayChange = ({ value }: CellProps) => (
|
||||
<Column gap="4">
|
||||
<Row justifyContent="flex-end" color="textPrimary">
|
||||
{value && value.value ? <>{formatWeiToDecimal(value.value.toString())} ETH</> : '-'}
|
||||
{value && value.value ? <>{formatWeiToDecimal(value.value.toString(), true)} ETH</> : '-'}
|
||||
</Row>
|
||||
{value.change ? (
|
||||
<Box
|
||||
|
@ -41,7 +41,11 @@ export const numberToWei = (amount: number) => {
|
||||
return parseEther(amount.toString())
|
||||
}
|
||||
|
||||
export const ethNumberStandardFormatter = (amount: string | number | undefined, includeDollarSign = false): string => {
|
||||
export const ethNumberStandardFormatter = (
|
||||
amount: string | number | undefined,
|
||||
includeDollarSign = false,
|
||||
removeZeroes = false
|
||||
): string => {
|
||||
if (!amount) return '-'
|
||||
|
||||
const amountInDecimals = parseFloat(amount.toString())
|
||||
@ -49,16 +53,13 @@ export const ethNumberStandardFormatter = (amount: string | number | undefined,
|
||||
|
||||
if (amountInDecimals < 0.0001) return `< ${conditionalDollarSign}0.00001`
|
||||
if (amountInDecimals < 1) return `${conditionalDollarSign}${amountInDecimals.toFixed(3)}`
|
||||
return (
|
||||
conditionalDollarSign +
|
||||
amountInDecimals
|
||||
.toFixed(2)
|
||||
.toString()
|
||||
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
)
|
||||
const formattedPrice = (removeZeroes ? parseFloat(amountInDecimals.toFixed(2)) : amountInDecimals.toFixed(2))
|
||||
.toString()
|
||||
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
return conditionalDollarSign + formattedPrice
|
||||
}
|
||||
|
||||
export const formatWeiToDecimal = (amount: string) => {
|
||||
export const formatWeiToDecimal = (amount: string, removeZeroes = false) => {
|
||||
if (!amount) return '-'
|
||||
return ethNumberStandardFormatter(formatEther(amount))
|
||||
return ethNumberStandardFormatter(formatEther(amount), false, removeZeroes)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user