Skip to content

Commit 5cedece

Browse files
committed
fix when downgrade
1 parent ce06db5 commit 5cedece

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/routes/(console)/organization-[organization]/billing/planSummary.svelte

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,14 @@
146146
id: 'base-plan',
147147
expandable: false,
148148
cells: {
149-
item: currentPlan?.price === 0 ? 'Free plan' : 'Base plan',
149+
item: 'Base plan',
150150
usage: '',
151-
price: formatCurrency(currentPlan?.price || 0)
151+
price: formatCurrency(
152+
Math.max(
153+
(currentAggregation?.amount ?? currentPlan?.price ?? 0) - availableCredit,
154+
0
155+
)
156+
)
152157
},
153158
children: []
154159
};
@@ -300,12 +305,12 @@
300305
$: billingData = getBillingData(currentPlan, currentAggregation, $isSmallViewport);
301306
302307
$: totalAmount = Math.max(
303-
(currentAggregation?.amount || currentPlan?.price || 0) - availableCredit,
308+
(currentAggregation?.amount ?? currentPlan?.price ?? 0) - availableCredit,
304309
0
305310
);
306311
307312
$: creditsApplied = Math.min(
308-
currentAggregation?.amount || currentPlan?.price || 0,
313+
currentAggregation?.amount ?? currentPlan?.price ?? 0,
309314
availableCredit
310315
);
311316
</script>
@@ -314,7 +319,7 @@
314319
<EstimatedCard>
315320
<Typography.Title size="s" gap="s">{currentPlan.name} plan</Typography.Title>
316321

317-
{#if currentPlan?.price > 0}
322+
{#if totalAmount > 0}
318323
<Typography.Text color="--fgcolor-neutral-secondary">
319324
Next payment of <span class="text --fgcolor-neutral-primary u-bold"
320325
>{formatCurrency(totalAmount)}</span>

0 commit comments

Comments
 (0)