feat: use only function from utilities for format

This commit is contained in:
RadoslavDimchev 2023-08-30 11:02:47 +03:00
parent 9aab726a4c
commit 66213d7f6f
4 changed files with 25 additions and 29 deletions

View File

@ -5,16 +5,17 @@ import Icon from '../../components/General/Icon'
import StandardGauge from '../../components/Charts/StandardGauge' import StandardGauge from '../../components/Charts/StandardGauge'
import IconText from '../../components/General/IconText' import IconText from '../../components/General/IconText'
import { TokenIcon } from '@status-im/icons' import { TokenIcon } from '@status-im/icons'
import { formatNumberForGauge } from '../../utilities'
interface DeviceStorageHealthProps { interface DeviceStorageHealthProps {
synced: number synced: number
total: number total: number
} }
const SyncStatusCardConsensus: React.FC<DeviceStorageHealthProps> = ({ synced, total }) => { const SyncStatusCardConsensus: React.FC<DeviceStorageHealthProps> = ({ synced, total }) => {
const message = synced === total ? 'Synced all data' : 'Syncing' const message = synced === total ? 'Synced all data' : 'Syncing'
const data = () => { const data = [
return [
{ {
id: 'storage', id: 'storage',
label: 'Used', label: 'Used',
@ -28,10 +29,7 @@ const SyncStatusCardConsensus: React.FC<DeviceStorageHealthProps> = ({ synced, t
color: '#E7EAEE', color: '#E7EAEE',
}, },
] ]
}
const formatNumber = (n: number): string => {
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
return ( return (
<Shadow <Shadow
variant="$2" variant="$2"
@ -63,7 +61,7 @@ const SyncStatusCardConsensus: React.FC<DeviceStorageHealthProps> = ({ synced, t
width: '115px', width: '115px',
}} }}
> >
<StandardGauge data={data()} /> <StandardGauge data={data} />
</Stack> </Stack>
</XStack> </XStack>
</YStack> </YStack>
@ -74,7 +72,7 @@ const SyncStatusCardConsensus: React.FC<DeviceStorageHealthProps> = ({ synced, t
<XStack space={'$2'} style={{ padding: '10px 16px 10px 16px' }}> <XStack space={'$2'} style={{ padding: '10px 16px 10px 16px' }}>
<IconText icon={<TokenIcon size={16} />}>{message}</IconText> <IconText icon={<TokenIcon size={16} />}>{message}</IconText>
<Text size={13}> <Text size={13}>
{formatNumber(synced)} / {formatNumber(total)} {formatNumberForGauge(synced)} / {formatNumberForGauge(total)}
</Text> </Text>
</XStack> </XStack>
</YStack> </YStack>

View File

@ -3,6 +3,7 @@ import { Shadow, Text } from '@status-im/components'
import StandardGauge from '../../components/Charts/StandardGauge' import StandardGauge from '../../components/Charts/StandardGauge'
import IconText from '../../components/General/IconText' import IconText from '../../components/General/IconText'
import { TokenIcon } from '@status-im/icons' import { TokenIcon } from '@status-im/icons'
import { formatNumberForGauge } from '../../utilities'
interface DeviceStorageHealthProps { interface DeviceStorageHealthProps {
synced: number synced: number
@ -27,9 +28,6 @@ const SyncStatusCardExecution: React.FC<DeviceStorageHealthProps> = ({ synced, t
}, },
] ]
} }
const formatNumber = (n: number): string => {
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
return ( return (
<Shadow <Shadow
@ -75,8 +73,7 @@ const SyncStatusCardExecution: React.FC<DeviceStorageHealthProps> = ({ synced, t
<XStack space={'$2'} style={{ padding: '10px 16px 10px 16px' }}> <XStack space={'$2'} style={{ padding: '10px 16px 10px 16px' }}>
<IconText icon={<TokenIcon size={16} />}>{message}</IconText> <IconText icon={<TokenIcon size={16} />}>{message}</IconText>
<Text size={13}> <Text size={13}>
{' '} {formatNumberForGauge(synced)} / {formatNumberForGauge(total)}
{formatNumber(synced)} / {formatNumber(total)}
</Text> </Text>
</XStack> </XStack>
</YStack> </YStack>

View File

@ -1,11 +1,11 @@
import { Stack, XStack, YStack } from 'tamagui' import { Stack, XStack, YStack } from 'tamagui'
import StandardGauge from '../../../components/Charts/StandardGauge' import StandardGauge from '../../../components/Charts/StandardGauge'
import { Text } from '@status-im/components' import { Text } from '@status-im/components'
import { formatNumberForGauge } from '../../../utilities'
type ActivationSyncCardProps = { type ActivationSyncCardProps = {
synced: number synced: number
total: number total: number
color: string color: string
} }
@ -37,7 +37,7 @@ const ActivationSyncCard = ({ synced, total, color }: ActivationSyncCardProps) =
</Stack> </Stack>
<YStack> <YStack>
<Text size={15} weight={'semibold'}> <Text size={15} weight={'semibold'}>
{synced} / {total} {formatNumberForGauge(synced)} / {formatNumberForGauge(total)}
</Text> </Text>
</YStack> </YStack>
</XStack> </XStack>

View File

@ -3,6 +3,7 @@ import StandardGauge from '../../../components/Charts/StandardGauge'
import { ClearIcon } from '@status-im/icons' import { ClearIcon } from '@status-im/icons'
import { Text } from '@status-im/components' import { Text } from '@status-im/components'
import BorderBox from '../../../components/General/BorderBox' import BorderBox from '../../../components/General/BorderBox'
import { formatNumberForGauge } from '../../../utilities'
type KeyGenerationSyncCardProps = { type KeyGenerationSyncCardProps = {
synced: number synced: number
@ -43,7 +44,7 @@ const KeyGenerationSyncCard = ({ synced, total, title, color }: KeyGenerationSyn
{title} {title}
</Text> </Text>
<Text size={15} weight={'semibold'}> <Text size={15} weight={'semibold'}>
{synced} / {total} {formatNumberForGauge(synced)} / {formatNumberForGauge(total)}
</Text> </Text>
</YStack> </YStack>
<ClearIcon size={20} color="#A1ABBD" /> <ClearIcon size={20} color="#A1ABBD" />