From b9bfc0b67133ec5bf413c464806fb0d6fe9557f5 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Wed, 21 Aug 2024 21:36:13 -0500 Subject: [PATCH] fix: show <0.001 instead of 0 when number gets small (#912) * show <0.001 instead of 0 when number gets small * extra check for timestamp ui removal --- .../Basenames/RegistrationForm/index.tsx | 17 +++++++++-------- apps/web/src/hooks/useActiveEthPremiumAmount.ts | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/Basenames/RegistrationForm/index.tsx b/apps/web/src/components/Basenames/RegistrationForm/index.tsx index fc9deabefd..ce237cc09f 100644 --- a/apps/web/src/components/Basenames/RegistrationForm/index.tsx +++ b/apps/web/src/components/Basenames/RegistrationForm/index.tsx @@ -105,12 +105,13 @@ export default function RegistrationForm() { const { data: initialPrice } = useNameRegistrationPrice(selectedName, years); const { data: singleYearEthCost } = useNameRegistrationPrice(selectedName, 1); const { basePrice: singleYearBasePrice, premiumPrice } = useRentPrice(selectedName, 1); - const formattedPremiumCost = Number(formatEther(premiumPrice ?? 0)).toLocaleString( - undefined, - { - maximumFractionDigits: 3, - }, - ); + const premiumValue = Number(formatEther(premiumPrice ?? 0)); + const formattedPremiumCost = + premiumValue < 0.001 + ? '<0.001' + : premiumValue.toLocaleString(undefined, { + maximumFractionDigits: 3, + }); const { data: discountedPrice } = useDiscountedNameRegistrationPrice( selectedName, years, @@ -163,9 +164,9 @@ export default function RegistrationForm() { const usdPrice = hasResolvedUSDPrice ? formatUsdPrice(price, ethUsdPrice) : '--.--'; const nameIsFree = !hasRegisteredWithDiscount && price === 0n; - const premiumEndTimestamp = usePremiumEndDurationRemaining(); + const { seconds, timestamp: premiumEndTimestamp } = usePremiumEndDurationRemaining(); - const isPremiumActive = premiumPrice && premiumPrice !== 0n; + const isPremiumActive = premiumPrice && premiumPrice !== 0n && seconds !== 0n; const mainRegistrationElementClasses = classNames( 'z-10 flex flex-col items-start justify-between gap-6 bg-[#F7F7F7] p-8 text-gray-60 shadow-xl md:flex-row md:items-center', { diff --git a/apps/web/src/hooks/useActiveEthPremiumAmount.ts b/apps/web/src/hooks/useActiveEthPremiumAmount.ts index 355480415b..8fb0c9726b 100644 --- a/apps/web/src/hooks/useActiveEthPremiumAmount.ts +++ b/apps/web/src/hooks/useActiveEthPremiumAmount.ts @@ -40,5 +40,5 @@ export function usePremiumEndDurationRemaining() { } }, 1000); - return timeLeft; + return { seconds: launchTimeSeconds, timestamp: timeLeft }; }