Skip to content

Commit

Permalink
fix: show <0.001 instead of 0 when number gets small (#912)
Browse files Browse the repository at this point in the history
* show <0.001 instead of 0 when number gets small

* extra check for timestamp ui removal
  • Loading branch information
JFrankfurt authored Aug 22, 2024
1 parent d2f8736 commit b9bfc0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions apps/web/src/components/Basenames/RegistrationForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
{
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/hooks/useActiveEthPremiumAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export function usePremiumEndDurationRemaining() {
}
}, 1000);

return timeLeft;
return { seconds: launchTimeSeconds, timestamp: timeLeft };
}

0 comments on commit b9bfc0b

Please sign in to comment.