fix formatNumbersWithComa

This commit is contained in:
Hristo Nedelkov 2023-09-21 09:53:54 +03:00
parent fc65965e18
commit 55ac55b53b
3 changed files with 10 additions and 8 deletions

View File

@ -3,7 +3,7 @@ import { Shadow, Text } from '@status-im/components'
import { SwapIcon } from '@status-im/icons'
import { CSSProperties } from 'react'
import { formatNumberWithComa } from '../../../utilities'
import { formatNumbersWithComa } from '../../../utilities'
import IconText from '../../../components/General/IconText'
import Icon from '../../../components/General/Icon'
import StandardGauge from '../../../components/Charts/StandardGauge'
@ -20,7 +20,7 @@ const ConsensusCard = ({ value, total, isTop }: ConsensusCardProps) => {
{
id: 'storage',
label: 'Used',
value,
value:value,
color: '#ff6161',
},
{
@ -61,7 +61,7 @@ const ConsensusCard = ({ value, total, isTop }: ConsensusCardProps) => {
<XStack space={'$3'} style={{ padding: '12px 16px' }}>
<IconText icon={<SwapIcon size={16} />}>Syncing</IconText>
<Text size={13} weight={'semibold'}>
{formatNumberWithComa(value)} / {formatNumberWithComa(total)}
{formatNumbersWithComa(value)} / {formatNumbersWithComa(total)}
</Text>
</XStack>
</YStack>

View File

@ -3,7 +3,7 @@ import { Shadow, Text } from '@status-im/components'
import { SwapIcon } from '@status-im/icons'
import { CSSProperties } from 'react'
import { formatNumberWithComa } from '../../../utilities'
import { formatNumbersWithComa } from '../../../utilities'
import IconText from '../../../components/General/IconText'
import StandardGauge from '../../../components/Charts/StandardGauge'
@ -62,7 +62,7 @@ const ExecutionClientCard = ({ value, total, isTop }: ExecutionClientCardProps)
<XStack space={'$3'} style={{ padding: '12px 16px' }}>
<IconText icon={<SwapIcon size={16} />}>Syncing</IconText>
<Text size={13} weight={'semibold'}>
{formatNumberWithComa(value)} / {formatNumberWithComa(total)}
{formatNumbersWithComa(value)} / {formatNumbersWithComa(total)}
</Text>
</XStack>
</YStack>

View File

@ -25,9 +25,11 @@ export const convertSecondsToTimerFormat = (seconds: number) => {
return `${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`
}
export const formatNumberWithComa = (n: number): string => {
return n.toFixed(3).replace(/\./g, ',')
}
export const formatNumbersWithComa = (n: number): string => {
const parts = n.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return parts.join('.');
};
export const getMonthIndicesFromRange = (range: DateRange) => {
if (!range.from || !range.to) return [0, 11]