Refactor billing components to improve price display and modularity (#132)

* Refactor billing components to improve price display and modularity
- Created new `PlanCostDisplay` component to centralize price formatting logic
- Simplified price rendering in plan picker and pricing table
- Removed redundant price calculation code
- Improved handling of metered and tiered pricing display
This commit is contained in:
Giancarlo Buomprisco
2025-02-03 12:06:40 +07:00
committed by GitHub
parent 001903ddac
commit f46286b503
4 changed files with 117 additions and 119 deletions

View File

@@ -242,12 +242,8 @@ function Tiers({
const isIncluded = tier.cost === 0;
return (
<span
className={'text-secondary-foreground flex gap-x-2 text-xs'}
key={index}
>
<span>-</span>
<span className={'text-secondary-foreground text-xs'} key={index}>
<span>-</span>{' '}
<If condition={isLastTier}>
<span className={'font-bold'}>
{formatCurrency({
@@ -255,8 +251,7 @@ function Tiers({
value: tier.cost,
locale,
})}
</span>
</span>{' '}
<If condition={tiersLength > 1}>
<span>
<Trans
@@ -268,7 +263,6 @@ function Tiers({
/>
</span>
</If>
<If condition={tiersLength === 1}>
<span>
<Trans
@@ -279,15 +273,13 @@ function Tiers({
/>
</span>
</If>
</If>
</If>{' '}
<If condition={!isLastTier}>
<If condition={isIncluded}>
<span>
<Trans i18nKey={'billing:includedUpTo'} values={{ unit, upTo }} />
</span>
</If>
</If>{' '}
<If condition={!isIncluded}>
<span className={'font-bold'}>
{formatCurrency({
@@ -295,8 +287,7 @@ function Tiers({
value: tier.cost,
locale,
})}
</span>
</span>{' '}
<span>
<Trans
i18nKey={'billing:fromPreviousTierUpTo'}