From 1134e73571b45975fda31228feae4b700f113614 Mon Sep 17 00:00:00 2001 From: Raquel Smith Date: Wed, 18 Oct 2023 13:05:28 -0700 Subject: [PATCH] use correct number of sig figs --- frontend/src/scenes/billing/PlanComparison.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/scenes/billing/PlanComparison.tsx b/frontend/src/scenes/billing/PlanComparison.tsx index 1d2c68bb9aa0b..646c553ce8dc8 100644 --- a/frontend/src/scenes/billing/PlanComparison.tsx +++ b/frontend/src/scenes/billing/PlanComparison.tsx @@ -49,6 +49,9 @@ const getProductTiers = ( ): JSX.Element => { const tiers = plan?.tiers + const allTierPrices = tiers?.map((tier) => parseFloat(tier.unit_amount_usd)) + const sigFigs = allTierPrices?.map((price) => price?.toString().split('.')[1]?.length).sort((a, b) => b - a)[0] + return ( <> {tiers ? ( @@ -63,7 +66,7 @@ const getProductTiers = ( {i === 0 && parseFloat(tier.unit_amount_usd) === 0 ? 'Free' - : `$${parseFloat(tier.unit_amount_usd).toFixed(6)}`} + : `$${parseFloat(tier.unit_amount_usd).toFixed(sigFigs)}`} ))