Skip to content

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

fix: replace db_pricing_plan with db_pricing_tier_id

phamhieucd913f83c6f3
diff --git a/studio/lib/constants/infrastructure.ts b/studio/lib/constants/infrastructure.ts
index 0b9c5a2e428..b1d2c65cb83 100644
--- a/studio/lib/constants/infrastructure.ts
+++ b/studio/lib/constants/infrastructure.ts
@@ -20,13 +20,18 @@ export const REGIONS = {
export const REGIONS_DEFAULT = REGIONS.EAST_US
-export const PRICING_PLANS = {
+export const PRICING_TIER_LABELS = {
FREE: 'Free tier',
PRO: 'Pro tier',
- // PAYG: 'Pay as you go',
}
-export const PRICING_PLANS_DEFAULT = PRICING_PLANS.FREE
+export const PRICING_TIER_PRODUCT_IDS = {
+ FREE: 'tier_free',
+ PRO: 'tier_pro',
+}
+
+export const PRICING_TIER_FREE_KEY = 'FREE'
+export const PRICING_TIER_DEFAULT_KEY = 'FREE'
export const PROVIDERS = {
AWS: {
diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx
index 6b012084196..3fe60a07230 100644
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@ -17,9 +17,11 @@ import {
REGIONS,
REGIONS_DEFAULT,
DEFAULT_MINIMUM_PASSWORD_STRENGTH,
- PRICING_PLANS,
- PRICING_PLANS_DEFAULT,
+ PRICING_TIER_LABELS,
+ PRICING_TIER_DEFAULT_KEY,
+ PRICING_TIER_FREE_KEY,
DEFAULT_FREE_PROJECTS_LIMIT,
+ PRICING_TIER_PRODUCT_IDS,
} from 'lib/constants'
import { useStore, withAuth, useSubscriptionStats } from 'hooks'
@@ -63,7 +65,7 @@ export const Wizard = observer(() => {
const [projectName, setProjectName] = useState('')
const [dbPass, setDbPass] = useState('')
const [dbRegion, setDbRegion] = useState(REGIONS_DEFAULT)
- const [dbPricingPlan, setDbPricingPlan] = useState(PRICING_PLANS_DEFAULT)
+ const [dbPricingTierKey, setDbPricingTierKey] = useState(PRICING_TIER_DEFAULT_KEY)
const [newProjectedLoading, setNewProjectLoading] = useState(false)
const [passwordStrengthMessage, setPasswordStrengthMessage] = useState('')
const [passwordStrengthWarning, setPasswordStrengthWarning] = useState('')
@@ -84,7 +86,7 @@ export const Wizard = observer(() => {
: undefined
const isOverFreeProjectLimit = totalFreeProjects >= freeProjectsLimit
const isInvalidSlug = isUndefined(currentOrg)
- const isSelectFreeTier = dbPricingPlan === PRICING_PLANS.FREE
+ const isSelectFreeTier = dbPricingTierKey === PRICING_TIER_FREE_KEY
const canCreateProject =
currentOrg?.is_owner &&
@@ -96,7 +98,7 @@ export const Wizard = observer(() => {
projectName != '' &&
passwordStrengthScore >= DEFAULT_MINIMUM_PASSWORD_STRENGTH &&
dbRegion != '' &&
- dbPricingPlan != '' &&
+ dbPricingTierKey != '' &&
(isSelectFreeTier || (!isSelectFreeTier && !isEmptyPaymentMethod))
const delayedCheckPasswordStrength = useRef(
@@ -158,7 +160,7 @@ export const Wizard = observer(() => {
}
function onDbPricingPlanChange(value: string) {
- setDbPricingPlan(value)
+ setDbPricingTierKey(value)
}
async function checkPasswordStrength(value: any) {
@@ -176,7 +178,7 @@ export const Wizard = observer(() => {
name: projectName,
db_pass: dbPass,
db_region: dbRegion,
- db_pricing_plan: dbPricingPlan,
+ db_pricing_tier_id: (PRICING_TIER_PRODUCT_IDS as any)[dbPricingTierKey],
}
const response = await post(`${API_URL}/projects`, data)
if (response.error) {
@@ -327,7 +329,7 @@ export const Wizard = observer(() => {
<Listbox
label="Pricing Plan"
layout="horizontal"
- value={dbPricingPlan}
+ value={dbPricingTierKey}
// @ts-ignore
onChange={onDbPricingPlanChange}
// @ts-ignore
@@ -340,9 +342,9 @@ export const Wizard = observer(() => {
</>
}
>
- {Object.entries(PRICING_PLANS).map(([k, v]) => (
- <Listbox.Option key={k} label={v} value={v}>
- {`${v}${v === PRICING_PLANS.PRO ? ' - $25/month' : ''}`}
+ {Object.entries(PRICING_TIER_LABELS).map(([k, v]) => (
+ <Listbox.Option key={k} label={v} value={k}>
+ {`${v}${k === 'PRO' ? ' - $25/month' : ''}`}
</Listbox.Option>
))}
</Listbox>
diff --git a/studio/pages/vercel/setupProject.tsx b/studio/pages/vercel/setupProject.tsx
index 5d2feb2abe6..ea4488e3d94 100644
--- a/studio/pages/vercel/setupProject.tsx
+++ b/studio/pages/vercel/setupProject.tsx
@@ -16,7 +16,7 @@ import {
REGIONS_DEFAULT,
DEFAULT_MINIMUM_PASSWORD_STRENGTH,
API_URL,
- PRICING_PLANS_DEFAULT,
+ PRICING_TIER_PRODUCT_IDS,
} from 'lib/constants'
import { VERCEL_INTEGRATION_CONFIGS } from 'lib/vercelConfigs'
import {
@@ -198,7 +198,7 @@ const CreateProject = observer(() => {
db_pass: dbPass,
db_region: dbRegion,
db_sql: dbSql || '',
- db_pricing_plan: PRICING_PLANS_DEFAULT,
+ db_pricing_tier_id: PRICING_TIER_PRODUCT_IDS.FREE,
auth_site_url: _store.selectedVercelProjectUrl,
vercel_configuration_id: _store.configurationId,
}