Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: possibly undefined breakdown in plan update modal (#36155)

Kevin Grüneberg2cd0f3c84d9d
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx
index 353e15b4525..0bee353c27b 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx
@@ -312,7 +312,8 @@ export const SubscriptionPlanUpdateDialog = ({
subscriptionPreview?.breakdown?.filter(
(item) =>
item.description?.toLowerCase().includes('compute') &&
- item.breakdown?.length > 0
+ item.breakdown &&
+ item.breakdown.length > 0
) || []
const computeCreditsItem =
@@ -325,11 +326,11 @@ export const SubscriptionPlanUpdateDialog = ({
)
const allProjects = computeItems.flatMap((item) =>
- item.breakdown.map((project) => ({
+ (item.breakdown || []).map((project) => ({
...project,
computeType: item.description,
computeCosts: Math.round(
- item.total_price / item.breakdown.length
+ item.total_price / item.breakdown!.length
),
}))
)
@@ -412,7 +413,7 @@ export const SubscriptionPlanUpdateDialog = ({
<TableCell className="text-xs py-2 px-0">
<div className="flex items-center gap-1">
<span>{item.description ?? 'Unknown'}</span>
- {item.breakdown.length > 0 && (
+ {item.breakdown && item.breakdown.length > 0 && (
<InfoTooltip className="max-w-sm">
<p>Projects using {item.description}:</p>
<ul className="ml-6 list-disc">
diff --git a/apps/studio/data/organizations/organization-billing-subscription-preview.ts b/apps/studio/data/organizations/organization-billing-subscription-preview.ts
index 75787a47e67..beb079b520e 100644
--- a/apps/studio/data/organizations/organization-billing-subscription-preview.ts
+++ b/apps/studio/data/organizations/organization-billing-subscription-preview.ts
@@ -16,7 +16,7 @@ export type OrganizationBillingSubscriptionPreviewResponse = {
unit_price_desc?: string
quantity?: number
total_price: number
- breakdown: {
+ breakdown?: {
project_name: string
project_ref: string
usage: number