Skip to content

Commit

Permalink
use correct number of sig figs
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelmsmith committed Oct 18, 2023
1 parent c98818a commit 1134e73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/scenes/billing/PlanComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
Expand All @@ -63,7 +66,7 @@ const getProductTiers = (
<span className="font-bold">
{i === 0 && parseFloat(tier.unit_amount_usd) === 0
? 'Free'
: `$${parseFloat(tier.unit_amount_usd).toFixed(6)}`}
: `$${parseFloat(tier.unit_amount_usd).toFixed(sigFigs)}`}
</span>
</div>
))
Expand Down

0 comments on commit 1134e73

Please sign in to comment.