fix: Handle Scientific Notation for NFT Collection Activity Prices (#6936)
wrap nft activity price in
This commit is contained in:
parent
e4dbef80eb
commit
da90738ba1
@ -1,6 +1,7 @@
|
||||
import { WatchQueryFetchPolicy } from '@apollo/client'
|
||||
import gql from 'graphql-tag'
|
||||
import { ActivityEvent } from 'nft/types'
|
||||
import { wrapScientificNotation } from 'nft/utils'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
|
||||
import { NftActivityFilterInput, useNftActivityQuery } from '../__generated__/types-and-hooks'
|
||||
@ -120,7 +121,7 @@ export function useNftActivity(filter: NftActivityFilterInput, first?: number, f
|
||||
toAddress: activity.toAddress,
|
||||
transactionHash: activity.transactionHash,
|
||||
orderStatus: activity.orderStatus,
|
||||
price: activity.price?.value.toString(),
|
||||
price: wrapScientificNotation(activity.price?.value),
|
||||
symbol: asset?.collection?.image?.url,
|
||||
quantity: activity.quantity,
|
||||
url: activity.url,
|
||||
|
@ -75,9 +75,8 @@ export const formatWeiToDecimal = (amount: string, removeZeroes = false) => {
|
||||
}
|
||||
|
||||
// prevent BigNumber overflow by properly handling scientific notation and comma delimited values
|
||||
export function wrapScientificNotation(value: string | number): string {
|
||||
return parseFloat(value.toString())
|
||||
.toLocaleString('fullwide', { useGrouping: false })
|
||||
.replace(',', '.')
|
||||
.replace(' ', '')
|
||||
export function wrapScientificNotation(value?: string | number): string {
|
||||
return value
|
||||
? parseFloat(value.toString()).toLocaleString('fullwide', { useGrouping: false }).replace(',', '.').replace(' ', '')
|
||||
: ''
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user