Skip to content

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

fix: do not block project/replica creation with due invoices on team/enterprise (#32612)

Kevin Grünebergc9f1827f82c3
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
index fce68e7f743..8742185a30b 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
@@ -1,6 +1,6 @@
import { ChevronDown } from 'lucide-react'
import Link from 'next/link'
-import { useEffect, useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
import { toast } from 'sonner'
import { useParams } from 'common'
@@ -79,14 +79,17 @@ const DeployNewReplicaPanel = ({
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })
const { data: diskConfiguration } = useDiskAttributesQuery({ projectRef })
+ const isNotOnTeamOrEnterprisePlan = useMemo(
+ () => !['team', 'enterprise'].includes(subscription?.plan.id ?? ''),
+ [subscription]
+ )
const { data: allOverdueInvoices } = useOverdueInvoicesQuery({
- enabled:
- subscription !== undefined && !['team', 'enterprise'].includes(subscription?.plan.id ?? ''),
+ enabled: isNotOnTeamOrEnterprisePlan,
})
const overdueInvoices = (allOverdueInvoices ?? []).filter(
(x) => x.organization_id === project?.organization_id
)
- const hasOverdueInvoices = overdueInvoices.length > 0
+ const hasOverdueInvoices = overdueInvoices.length > 0 && isNotOnTeamOrEnterprisePlan
// Opting for useState temporarily as Listbox doesn't seem to work with react-hook-form yet
const [defaultRegion] = Object.entries(AWS_REGIONS).find(
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index 31e6a141987..8a66b06d515 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -4,7 +4,7 @@ import { debounce } from 'lodash'
import { ExternalLink } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import { PropsWithChildren, useEffect, useRef, useState } from 'react'
+import { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import { z } from 'zod'
@@ -149,15 +149,19 @@ const Wizard: NextPageWithLayout = () => {
const { data: orgSubscription } = useOrgSubscriptionQuery({ orgSlug: slug })
+ const isNotOnTeamOrEnterprisePlan = useMemo(
+ () => !['team', 'enterprise'].includes(orgSubscription?.plan.id ?? ''),
+ [orgSubscription]
+ )
+
const { data: allOverdueInvoices } = useOverdueInvoicesQuery({
- enabled:
- orgSubscription !== undefined &&
- !['team', 'enterprise'].includes(orgSubscription?.plan.id ?? ''),
+ enabled: isNotOnTeamOrEnterprisePlan,
})
+
const overdueInvoices = (allOverdueInvoices ?? []).filter(
(x) => x.organization_id === currentOrg?.id
)
- const hasOutstandingInvoices = overdueInvoices.length > 0
+ const hasOutstandingInvoices = overdueInvoices.length > 0 && isNotOnTeamOrEnterprisePlan
const { data: allProjects } = useProjectsQuery({})
const organizationProjects =