Skip to content

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

[Fix]: Handle undefined report.availableIn and improve plan display in ReportChartUpsell (#39451) (#39648)

Aditya kumar singhd6281969a41b
diff --git a/apps/studio/components/interfaces/Reports/v2/ReportChartUpsell.tsx b/apps/studio/components/interfaces/Reports/v2/ReportChartUpsell.tsx
index 77bda75ecc7..15fd4fb0173 100644
--- a/apps/studio/components/interfaces/Reports/v2/ReportChartUpsell.tsx
+++ b/apps/studio/components/interfaces/Reports/v2/ReportChartUpsell.tsx
@@ -44,7 +44,9 @@ export const ReportChartUpsell = ({ report, orgSlug }: ReportsChartUpsellProps)
<p className="text-sm text-foreground-light">
This chart is available from{' '}
<span className="capitalize">
- {!!report.availableIn?.length ? report.availableIn[0] : 'Pro'}
+ {Array.isArray(report.availableIn) && report.availableIn.length > 0
+ ? report.availableIn[0]
+ : 'Pro'}
</span>{' '}
plan and above
</p>
@@ -58,7 +60,9 @@ export const ReportChartUpsell = ({ report, orgSlug }: ReportsChartUpsellProps)
<Link href={`/org/${orgSlug || '_'}/billing?panel=subscriptionPlan&source=reports`}>
Upgrade to{' '}
<span className="capitalize">
- {!!report.availableIn?.length ? report.availableIn[0] : 'Pro'}
+ {Array.isArray(report.availableIn) && report.availableIn.length > 0
+ ? report.availableIn[0]
+ : 'Pro'}
</span>
</Link>
</Button>
diff --git a/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx b/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
index 769ee3b4bac..d1ab6e80ac1 100644
--- a/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
+++ b/apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
@@ -68,8 +68,7 @@ export const ReportChartV2 = ({
const { plan: orgPlan } = useCurrentOrgPlan()
const orgPlanId = orgPlan?.id
- const isAvailable =
- report.availableIn === undefined || (orgPlanId && report.availableIn.includes(orgPlanId))
+ const isAvailable = !report?.availableIn || (orgPlanId && report.availableIn?.includes(orgPlanId))
const canFetch = orgPlanId !== undefined && isAvailable