diff --git a/src/components/common/CreatorCard.tsx b/src/components/common/CreatorCard.tsx index 9005bc2c..1a6a4802 100644 --- a/src/components/common/CreatorCard.tsx +++ b/src/components/common/CreatorCard.tsx @@ -22,6 +22,7 @@ import CreatorListRowDivider from '@/components/common/CreatorListRowDivider'; import BuyActionHelperText from '@/components/common/BuyActionHelperText'; import CreatorLabeledStatRow from '@/components/common/CreatorLabeledStatRow'; import { useTransactionTelemetry } from '@/hooks/useTransactionTelemetry'; +import { formatCompactNumber, formatNumber } from '@/utils/numberFormat.utils'; interface CreatorCardProps { creator: Course; @@ -116,7 +117,7 @@ const CreatorCard: React.FC = ({ creator, className }) => { {creator.volume24h > 0 - ? `${creator.volume24h} ETH` + ? `${formatCompactNumber(creator.volume24h)} ETH` : 'New'} @@ -157,7 +158,7 @@ const CreatorCard: React.FC = ({ creator, className }) => {
- + = ({ creator, className }) => { label="Creator Share Supply" value={ creator.creatorShareSupply - ? `${creator.creatorShareSupply} shares` + ? `${formatCompactNumber(creator.creatorShareSupply)} shares` : 'Supply pending' } className="px-3 py-3" @@ -202,7 +203,7 @@ const CreatorCard: React.FC = ({ creator, className }) => { /> diff --git a/src/components/common/KeySupplyBadge.tsx b/src/components/common/KeySupplyBadge.tsx index 984f7ecd..cffdc04a 100644 --- a/src/components/common/KeySupplyBadge.tsx +++ b/src/components/common/KeySupplyBadge.tsx @@ -3,6 +3,7 @@ import { Key } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Tooltip } from '@/components/ui/tooltip'; import { formatRelativeTime, type TooltipContent } from '@/utils/keyPrice.utils'; +import { formatCompactNumber, formatNumber } from '@/utils/numberFormat.utils'; interface KeySupplyBadgeProps { /** Total key supply. Undefined or null renders a graceful placeholder. */ @@ -11,16 +12,6 @@ interface KeySupplyBadgeProps { tooltipContent?: TooltipContent; } -function formatSupply(supply: number): string { - if (supply >= 1_000_000) { - return `${(supply / 1_000_000).toFixed(1).replace(/\.0$/, '')}M`; - } - if (supply >= 1_000) { - return `${(supply / 1_000).toFixed(1).replace(/\.0$/, '')}K`; - } - return supply.toString(); -} - function KeyPriceTooltipContent({ lastUpdated, quoteSource }: TooltipContent) { const timeLabel = formatRelativeTime(lastUpdated); const sourceLabel = quoteSource?.trim() ? `Source: ${quoteSource}` : 'Source: N/A'; @@ -45,10 +36,10 @@ const KeySupplyBadge: React.FC = ({ supply, className, tool : 'border-white/10 bg-white/[0.06] text-white/40', className )} - title={hasData ? `${supply} keys available` : 'Supply not available'} + title={hasData ? `${formatNumber(supply)} keys available` : 'Supply not available'} >