Skip to content

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

fix(studio): guard priceMonthly lookup on new project page (#46395)

Ali Waseem95a38ef9a52c
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationFooter.tsx b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationFooter.tsx
index ff1bf50028a..2352580003f 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationFooter.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationFooter.tsx
@@ -17,7 +17,6 @@ import { InfoTooltip } from 'ui-patterns/info-tooltip'
import { CreateProjectForm } from './ProjectCreation.schema'
import { instanceLabel, monthlyInstancePrice } from './ProjectCreation.utils'
import { InlineLink } from '@/components/ui/InlineLink'
-import { DesiredInstanceSize, instanceSizeSpecs } from '@/data/projects/new-project.constants'
import { OrgProject } from '@/data/projects/org-projects-infinite-query'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
@@ -54,7 +53,7 @@ export const ProjectCreationFooter = ({
const availableComputeCredits = organizationProjects.length === 0 ? 10 : 0
const additionalMonthlySpend = isFreePlan
? 0
- : instanceSizeSpecs[instanceSize as DesiredInstanceSize]!.priceMonthly - availableComputeCredits
+ : monthlyInstancePrice(instanceSize) - availableComputeCredits
// [kevin] This will eventually all be provided by a new API endpoint to preview and validate project creation, this is just for kaizen now
const monthlyComputeCosts =
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index 266d8a0e62d..6ab70961c77 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -26,6 +26,7 @@ import { sizes } from '@/components/interfaces/ProjectCreation/ProjectCreation.c
import { FormSchema } from '@/components/interfaces/ProjectCreation/ProjectCreation.schema'
import {
instanceLabel,
+ monthlyInstancePrice,
smartRegionToExactRegion,
} from '@/components/interfaces/ProjectCreation/ProjectCreation.utils'
import { ProjectCreationFooter } from '@/components/interfaces/ProjectCreation/ProjectCreationFooter'
@@ -46,7 +47,7 @@ import { useAuthorizedAppsQuery } from '@/data/oauth/authorized-apps-query'
import { useFreeProjectLimitCheckQuery } from '@/data/organizations/free-project-limit-check-query'
import { useOrganizationAvailableRegionsQuery } from '@/data/organizations/organization-available-regions-query'
import { useOrganizationsQuery } from '@/data/organizations/organizations-query'
-import { DesiredInstanceSize, instanceSizeSpecs } from '@/data/projects/new-project.constants'
+import { DesiredInstanceSize } from '@/data/projects/new-project.constants'
import {
OrgProject,
useOrgProjectsInfiniteQuery,
@@ -227,7 +228,7 @@ const Wizard: NextPageWithLayout = () => {
const availableComputeCredits = organizationProjects.length === 0 ? 10 : 0
const additionalMonthlySpend = isFreePlan
? 0
- : instanceSizeSpecs[instanceSize as DesiredInstanceSize]!.priceMonthly - availableComputeCredits
+ : monthlyInstancePrice(instanceSize) - availableComputeCredits
const { data: _defaultRegion, error: defaultRegionError } = useDefaultRegionQuery(
{