Skip to content

Commit d628196

Browse files
authored
[Fix]: Handle undefined report.availableIn and improve plan display in ReportChartUpsell (supabase#39451) (supabase#39648)
* Fixes: supabase#39451 * commit * d * yes * format fix * Fix import statement in table-row-query test
1 parent 5606d07 commit d628196

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

apps/studio/components/interfaces/Reports/v2/ReportChartUpsell.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const ReportChartUpsell = ({ report, orgSlug }: ReportsChartUpsellProps)
4444
<p className="text-sm text-foreground-light">
4545
This chart is available from{' '}
4646
<span className="capitalize">
47-
{!!report.availableIn?.length ? report.availableIn[0] : 'Pro'}
47+
{Array.isArray(report.availableIn) && report.availableIn.length > 0
48+
? report.availableIn[0]
49+
: 'Pro'}
4850
</span>{' '}
4951
plan and above
5052
</p>
@@ -58,7 +60,9 @@ export const ReportChartUpsell = ({ report, orgSlug }: ReportsChartUpsellProps)
5860
<Link href={`/org/${orgSlug || '_'}/billing?panel=subscriptionPlan&source=reports`}>
5961
Upgrade to{' '}
6062
<span className="capitalize">
61-
{!!report.availableIn?.length ? report.availableIn[0] : 'Pro'}
63+
{Array.isArray(report.availableIn) && report.availableIn.length > 0
64+
? report.availableIn[0]
65+
: 'Pro'}
6266
</span>
6367
</Link>
6468
</Button>

apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ export const ReportChartV2 = ({
6868
const { plan: orgPlan } = useCurrentOrgPlan()
6969
const orgPlanId = orgPlan?.id
7070

71-
const isAvailable =
72-
report.availableIn === undefined || (orgPlanId && report.availableIn.includes(orgPlanId))
71+
const isAvailable = !report?.availableIn || (orgPlanId && report.availableIn?.includes(orgPlanId))
7372

7473
const canFetch = orgPlanId !== undefined && isAvailable
7574

0 commit comments

Comments
 (0)