The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add custom domains as billing add on
Joshen Limd0416ea42558
diff --git a/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts b/studio/components/interfaces/Billing/AddOns/AddOns.utils.tsindex d3d559d3abf..4440c0a0f78 100644--- a/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts+++ b/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts@@ -91,3 +91,39 @@ export const formatPITROptions = (addons: DatabaseAddon[]) => {if (pitrOptions.length === 0) return []else return [noPITROption].concat(pitrOptions)}++export const formatCustomDomainOptions = (addons: DatabaseAddon[]) => {+ const customDomainOrder = ['addon_custom_domains']+ const noCustomDomainOption: DatabaseAddon = {+ id: undefined,+ name: 'Disable Custom Domains',+ metadata: {+ default_price_id: undefined,+ supabase_prod_id: 'addon_custom_domains_disabled',+ features: '',+ },+ prices: [+ {+ id: undefined,+ currency: 'usd',+ recurring: {+ interval: 'month',+ usage_type: 'licensed',+ interval_count: 1,+ aggregate_usage: null,+ trial_period_days: null,+ },+ unit_amount: 0,+ },+ ],+ }++ const customDomainOptions = customDomainOrder+ .map((id: string) => {+ return addons.find((option) => option.metadata.supabase_prod_id === id)+ })+ .filter((option) => option !== undefined) as DatabaseAddon[]++ if (customDomainOptions.length === 0) return []+ else return [noCustomDomainOption].concat(customDomainOptions)+}diff --git a/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsxnew file mode 100644index 00000000000..a43d9f17f34--- /dev/null+++ b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx@@ -0,0 +1,70 @@+import { FC } from 'react'+import { Badge, Radio } from 'ui'++import { useStore, useFlag } from 'hooks'+import { getProductPrice } from '../Billing.utils'+import DisabledWarningDueToIncident from 'components/ui/DisabledWarningDueToIncident'++interface Props {+ options: any[]+ currentOption?: any+ selectedOption: any+ onSelectOption: (option: any) => void+}++const CustomDomainSelection: FC<Props> = ({+ options,+ currentOption,+ selectedOption,+ onSelectOption,+}) => {+ const addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')+ return (+ <div className="space-y-4">+ <div>+ <div className="flex items-center space-x-2">+ <h4 className="text-lg">Custom Domains</h4>+ <Badge color="green">Optional</Badge>+ </div>+ <p className="text-sm text-scale-1100">Present a branded experience to your users</p>+ </div>+ {addonUpdateDisabled ? (+ <DisabledWarningDueToIncident title="Updating database add-ons is currently disabled" />+ ) : (+ <Radio.Group type="cards" className="billing-compute-radio">+ {options.map((option: any) => {+ const defaultPrice = getProductPrice(option)+ return (+ <Radio+ hidden+ key={option.id || 'micro-add-on'}+ align="vertical"+ // @ts-ignore+ label={+ <div className="flex items-center space-x-4">+ <p>{option.name}</p>+ {currentOption?.id === option.id && (+ <Badge color="brand">Current selection</Badge>+ )}+ </div>+ }+ // @ts-ignore+ description={+ <div>+ <p>{option.metadata.features}</p>+ </div>+ }+ value={option.id}+ optionalLabel={<div>${defaultPrice.unit_amount / 100} / month</div>}+ checked={selectedOption?.id === option.id}+ onChange={() => onSelectOption(option)}+ />+ )+ })}+ </Radio.Group>+ )}+ </div>+ )+}++export default CustomDomainSelectiondiff --git a/studio/components/interfaces/Billing/Billing.utils.ts b/studio/components/interfaces/Billing/Billing.utils.tsindex 2c839e9459a..d6d21a9652f 100644--- a/studio/components/interfaces/Billing/Billing.utils.ts+++ b/studio/components/interfaces/Billing/Billing.utils.ts@@ -1,5 +1,9 @@import { DatabaseAddon } from './AddOns/AddOns.types'-import { formatComputeSizes, formatPITROptions } from './AddOns/AddOns.utils'+import {+ formatComputeSizes,+ formatCustomDomainOptions,+ formatPITROptions,+} from './AddOns/AddOns.utils'import { StripeSubscription } from './Subscription/Subscription.types'export const getProductPrice = (product: any) => {@@ -11,11 +15,15 @@ export const getProductPrice = (product: any) => {return price}-export const validateSubscriptionUpdatePayload = (- selectedComputeSize: DatabaseAddon,- selectedPITRDuration?: DatabaseAddon-) => {- if (selectedPITRDuration?.id !== undefined && selectedComputeSize.id === undefined) {+export const validateSubscriptionUpdatePayload = (selectedAddons: {+ computeSize: DatabaseAddon+ pitrDuration: DatabaseAddon+ customDomains: DatabaseAddon+}) => {+ if (+ selectedAddons.pitrDuration?.id !== undefined &&+ selectedAddons.computeSize.id === undefined+ ) {return 'To enable PITR for your project, your project must minimally be on a Small Add-on.'}return undefined@@ -23,18 +31,24 @@ export const validateSubscriptionUpdatePayload = (export const formSubscriptionUpdatePayload = (selectedTier: any,- selectedComputeSize: DatabaseAddon,- selectedPITRDuration: DatabaseAddon | undefined,+ selectedAddons: {+ computeSize: DatabaseAddon+ pitrDuration: DatabaseAddon+ customDomains: DatabaseAddon+ },selectedPaymentMethod: string,region: string) => {+ const { computeSize, pitrDuration, customDomains } = selectedAddonsconst defaultPrice = selectedTier ? getProductPrice(selectedTier) : undefinedconst addons =region === 'af-south-1'? []- : [selectedComputeSize.prices[0].id, selectedPITRDuration?.prices?.[0].id].filter(- (x) => x !== undefined- )+ : [+ computeSize.prices[0].id,+ pitrDuration?.prices?.[0].id,+ customDomains?.prices?.[0].id,+ ].filter((x) => x !== undefined)const proration_date = Math.floor(Date.now() / 1000)return {...(defaultPrice && { tier: defaultPrice.id }),@@ -50,8 +64,9 @@ export const getCurrentAddons = () => {const computeSizes = formatComputeSizes(addons)const pitrDurationOptions = formatPITROptions(addons)+ const customDomainOptions = formatCustomDomainOptions(addons)- const currentComputeSize =+ const computeSize =computeSizes.find((option: any) => {const subscriptionComputeSize = currentSubscription?.addons.find((addon) =>addon.supabase_prod_id.includes('_instance_')@@ -62,7 +77,7 @@ export const getCurrentAddons = ((option: any) => option.metadata.supabase_prod_id === 'addon_instance_micro') as DatabaseAddon)- const currentPITRDuration =+ const pitrDuration =pitrDurationOptions.find((option: any) => {const subscriptionComputeSize = currentSubscription?.addons.find((addon) =>addon.supabase_prod_id.includes('_pitr_')@@ -73,5 +88,16 @@ export const getCurrentAddons = ((option: any) => option.metadata.supabase_prod_id === 'addon_pitr_0days') as DatabaseAddon)- return { currentComputeSize, currentPITRDuration }+ const customDomains =+ customDomainOptions.find((option: any) => {+ const subscriptionComputeSize = currentSubscription?.addons.find((addon) =>+ addon.supabase_prod_id.includes('_custom_domains')+ )+ return option.id === subscriptionComputeSize?.prod_id+ }) ||+ (customDomainOptions.find(+ (option: any) => option.metadata.supabase_prod_id === 'addon__custom_domains_disabled'+ ) as DatabaseAddon)++ return { computeSize, pitrDuration, customDomains }}diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsxindex 360c2f96987..504d5931f8a 100644--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx@@ -2,14 +2,18 @@ import { FC, useState, useEffect } from 'react'import { useRouter } from 'next/router'import { Transition } from '@headlessui/react'-import { useStore } from 'hooks'+import { useStore, useFlag } from 'hooks'import { getURL } from 'lib/helpers'import { post, patch } from 'lib/common/fetch'import { API_URL, PROJECT_STATUS } from 'lib/constants'import Divider from 'components/ui/Divider'import { DatabaseAddon } from './AddOns/AddOns.types'-import { formatComputeSizes, formatPITROptions } from './AddOns/AddOns.utils'+import {+ formatComputeSizes,+ formatCustomDomainOptions,+ formatPITROptions,+} from './AddOns/AddOns.utils'import {AddNewPaymentMethodModal,ComputeSizeSelection,@@ -17,6 +21,7 @@ import {StripeSubscription,PaymentSummaryPanel,UpdateSuccess,+ CustomDomainSelection,} from './'import { PaymentMethod, SubscriptionPreview } from './Billing.types'import { formSubscriptionUpdatePayload, getCurrentAddons } from './Billing.utils'@@ -36,6 +41,8 @@ const EnterpriseUpdate: FC<Props> = ({}) => {const { app, ui } = useStore()const router = useRouter()+ const isCustomDomainsEnabled = useFlag('customDomains')+ const isPITRSelfServeEnabled = useFlag('pitrSelfServe')const projectId = ui.selectedProject?.id ?? -1const projectRef = ui.selectedProject?.ref ?? 'default'@@ -44,12 +51,30 @@ const EnterpriseUpdate: FC<Props> = ({const { addons } = productsconst computeSizes = formatComputeSizes(addons)const pitrDurationOptions = formatPITROptions(addons)- const { currentComputeSize, currentPITRDuration } = getCurrentAddons(currentSubscription, addons)+ const customDomainOptions = formatCustomDomainOptions(addons)+ const currentAddons = getCurrentAddons(currentSubscription, addons)++ // [Joshen TODO] Ideally we just have a state to hold all the add ons selection, rather than individual+ // Even better if we can just use the <Form> component to handle all of these. Mainly to reduce the amount+ // of unnecessary state management on this complex page.+ const [selectedComputeSize, setSelectedComputeSize] = useState<DatabaseAddon>(+ currentAddons.computeSize+ )+ const [selectedPITRDuration, setSelectedPITRDuration] = useState<DatabaseAddon>(+ currentAddons.pitrDuration+ )+ const [selectedCustomDomainOption, setSelectedCustomDomainOption] = useState<DatabaseAddon>(+ currentAddons.customDomains+ )++ // [Joshen] Scaffolded here+ const selectedAddons = {+ computeSize: selectedComputeSize,+ pitrDuration: selectedPITRDuration,+ customDomains: selectedCustomDomainOption,+ }const [selectedPaymentMethodId, setSelectedPaymentMethodId] = useState<any>()- const [selectedComputeSize, setSelectedComputeSize] = useState<DatabaseAddon>(currentComputeSize)- const [selectedPITRDuration, setSelectedPITRDuration] =- useState<DatabaseAddon>(currentPITRDuration)const [subscriptionPreview, setSubscriptionPreview] = useState<SubscriptionPreview>()const [isRefreshingPreview, setIsRefreshingPreview] = useState(false)@@ -57,7 +82,7 @@ const EnterpriseUpdate: FC<Props> = ({const [isSuccessful, setIsSuccessful] = useState(false)const [showAddPaymentMethodModal, setShowAddPaymentMethodModal] = useState(false)- const isChangingComputeSize = currentComputeSize?.id !== selectedComputeSize.id+ const isChangingComputeSize = currentAddons.computeSize?.id !== selectedAddons.computeSize.iduseEffect(() => {getSubscriptionPreview()@@ -75,8 +100,7 @@ const EnterpriseUpdate: FC<Props> = ({const payload = {...formSubscriptionUpdatePayload(null,- selectedComputeSize,- selectedPITRDuration,+ selectedAddons,selectedPaymentMethodId,projectRegion),@@ -100,8 +124,7 @@ const EnterpriseUpdate: FC<Props> = ({const payload = {...formSubscriptionUpdatePayload(null,- selectedComputeSize,- selectedPITRDuration,+ selectedAddons,selectedPaymentMethodId,projectRegion),@@ -176,13 +199,24 @@ const EnterpriseUpdate: FC<Props> = ({</div>{projectRegion !== 'af-south-1' && (<>- {pitrDurationOptions.length > 0 && (+ {isCustomDomainsEnabled && customDomainOptions.length > 0 && (+ <>+ <Divider light />+ <CustomDomainSelection+ options={customDomainOptions}+ currentOption={currentAddons.customDomains}+ selectedOption={selectedAddons.customDomains}+ onSelectOption={setSelectedCustomDomainOption}+ />+ </>+ )}+ {isPITRSelfServeEnabled && pitrDurationOptions.length > 0 && (<><Divider light /><PITRDurationSelectionpitrDurationOptions={pitrDurationOptions}- currentPitrDuration={currentPITRDuration}- selectedPitrDuration={selectedPITRDuration}+ currentPitrDuration={currentAddons.pitrDuration}+ selectedPitrDuration={selectedAddons.pitrDuration}onSelectOption={setSelectedPITRDuration}/></>@@ -190,8 +224,8 @@ const EnterpriseUpdate: FC<Props> = ({<Divider light /><ComputeSizeSelectioncomputeSizes={computeSizes || []}- currentComputeSize={currentComputeSize}- selectedComputeSize={selectedComputeSize}+ currentComputeSize={currentAddons.computeSize}+ selectedComputeSize={selectedAddons.computeSize}onSelectOption={setSelectedComputeSize}/></>@@ -208,11 +242,9 @@ const EnterpriseUpdate: FC<Props> = ({subscriptionPreview={subscriptionPreview}// Current subscription configuration based on DBcurrentPlan={currentSubscription.tier}- currentComputeSize={currentComputeSize}- currentPITRDuration={currentPITRDuration}+ currentAddons={currentAddons}// Selected subscription configuration based on UI- selectedComputeSize={selectedComputeSize}- selectedPITRDuration={selectedPITRDuration}+ selectedAddons={selectedAddons}paymentMethods={paymentMethods}isLoadingPaymentMethods={isLoadingPaymentMethods}selectedPaymentMethod={selectedPaymentMethodId}diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsxindex 6f53bc8760d..dcda2e2c66b 100644--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx@@ -18,12 +18,21 @@ import ConfirmPaymentModal from './ConfirmPaymentModal'interface Props {isRefreshingPreview: booleansubscriptionPreview?: SubscriptionPreview+currentPlan: any- currentComputeSize: DatabaseAddon- currentPITRDuration: DatabaseAddon | undefined+ currentAddons: {+ computeSize: DatabaseAddon+ pitrDuration: DatabaseAddon+ customDomains: DatabaseAddon+ }+selectedPlan?: any- selectedComputeSize: DatabaseAddon- selectedPITRDuration: DatabaseAddon | undefined+ selectedAddons: {+ computeSize: DatabaseAddon+ pitrDuration: DatabaseAddon+ customDomains: DatabaseAddon+ }+isSpendCapEnabled: booleanpaymentMethods?: anyselectedPaymentMethod: any@@ -45,12 +54,13 @@ const PaymentSummaryPanel: FC<Props> = ({isRefreshingPreview,isSpendCapEnabled,subscriptionPreview,+currentPlan,- currentComputeSize,- currentPITRDuration,+ currentAddons,+selectedPlan,- selectedComputeSize,- selectedPITRDuration,+ selectedAddons,+paymentMethods,selectedPaymentMethod,isLoadingPaymentMethods,@@ -70,9 +80,10 @@ const PaymentSummaryPanel: FC<Props> = ({const [showConfirmModal, setShowConfirmModal] = useState(false)- const currentPITRDays = currentPITRDuration !== undefined ? getPITRDays(currentPITRDuration) : 0+ const currentPITRDays =+ currentAddons.pitrDuration !== undefined ? getPITRDays(currentAddons.pitrDuration) : 0const selectedPITRDays =- selectedPITRDuration !== undefined ? getPITRDays(selectedPITRDuration) : 0+ selectedAddons.pitrDuration !== undefined ? getPITRDays(selectedAddons.pitrDuration) : 0const isEnterprise = currentPlan.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEconst isChangingPlan =@@ -81,8 +92,10 @@ const PaymentSummaryPanel: FC<Props> = ({currentPlan.prod_id !== selectedPlan.id) ||(currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && !isSpendCapEnabled) ||(currentPlan.prod_id === STRIPE_PRODUCT_IDS.PAYG && isSpendCapEnabled)- const isChangingComputeSize = currentComputeSize.id !== selectedComputeSize.id- const isChangingPITRDuration = currentPITRDuration?.id !== selectedPITRDuration?.id+ const isChangingComputeSize = currentAddons.computeSize.id !== selectedAddons.computeSize.id+ const isChangingPITRDuration = currentAddons.pitrDuration?.id !== selectedAddons.pitrDuration?.id+ const isChangingCustomDomains =+ currentAddons.customDomains?.id !== selectedAddons.customDomains?.id// If it's enterprise we only only changing of add-onsconst hasChangesToPlan = isEnterprise@@ -96,7 +109,7 @@ const PaymentSummaryPanel: FC<Props> = ({}const validateOrder = () => {- const error = validateSubscriptionUpdatePayload(selectedComputeSize, selectedPITRDuration)+ const error = validateSubscriptionUpdatePayload(selectedAddons)if (error) {return ui.setNotification({duration: 4000,@@ -147,45 +160,71 @@ const PaymentSummaryPanel: FC<Props> = ({<pclassName={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>- {currentComputeSize.name}+ {currentAddons.computeSize.name}</p><pclassName={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>- ${(getProductPrice(currentComputeSize).unit_amount / 100).toFixed(2)}+ ${(getProductPrice(currentAddons.computeSize).unit_amount / 100).toFixed(2)}</p></div>{isChangingComputeSize && (<div className="flex items-center justify-between">- <p className="text-sm">{selectedComputeSize.name}</p>+ <p className="text-sm">{selectedAddons.computeSize.name}</p><p className="text-sm">- ${(getProductPrice(selectedComputeSize).unit_amount / 100).toFixed(2)}+ ${(getProductPrice(selectedAddons.computeSize).unit_amount / 100).toFixed(2)}</p></div>)}- {currentPITRDuration?.id !== undefined && (+ {currentAddons.pitrDuration?.id !== undefined && (<div className="flex items-center justify-between"><pclassName={`${isChangingPITRDuration ? 'text-scale-1100 line-through' : ''} text-sm`}>- {currentPITRDuration?.name}+ {currentAddons.pitrDuration?.name}</p><pclassName={`${isChangingPITRDuration ? 'text-scale-1100 line-through' : ''} text-sm`}>- ${(getProductPrice(currentPITRDuration).unit_amount / 100).toFixed(2)}+ ${(getProductPrice(currentAddons.pitrDuration).unit_amount / 100).toFixed(2)}</p></div>)}{isChangingPITRDuration && (<div className="flex items-center justify-between">- <p className="text-sm">{selectedPITRDuration?.name}</p>+ <p className="text-sm">{selectedAddons.pitrDuration?.name}</p>+ <p className="text-sm">+ ${(getProductPrice(selectedAddons.pitrDuration).unit_amount / 100).toFixed(2)}+ </p>+ </div>+ )}+ {currentAddons.customDomains?.id !== undefined && (+ <div className="flex items-center justify-between">+ <p+ className={`${+ isChangingCustomDomains ? 'text-scale-1100 line-through' : ''+ } text-sm`}+ >+ {currentAddons.customDomains?.name}+ </p>+ <p+ className={`${+ isChangingCustomDomains ? 'text-scale-1100 line-through' : ''+ } text-sm`}+ >+ ${(getProductPrice(currentAddons.customDomains).unit_amount / 100).toFixed(2)}+ </p>+ </div>+ )}+ {isChangingCustomDomains && (+ <div className="flex items-center justify-between">+ <p className="text-sm">{selectedAddons.customDomains?.name}</p><p className="text-sm">- ${(getProductPrice(selectedPITRDuration).unit_amount / 100).toFixed(2)}+ ${(getProductPrice(selectedAddons.customDomains).unit_amount / 100).toFixed(2)}</p></div>)}@@ -198,9 +237,9 @@ const PaymentSummaryPanel: FC<Props> = ({defaultVisibilityicon={<IconAlertCircle strokeWidth={2} />}title={- currentPITRDuration?.id === undefined+ currentAddons.pitrDuration?.id === undefined? 'Enabling PITR'- : selectedPITRDuration?.id === undefined+ : selectedAddons.pitrDuration?.id === undefined? 'Disabling PITR': 'Updating PITR duration'}diff --git a/studio/components/interfaces/Billing/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsxindex 12fea2c0c3b..5ff559adc1a 100644--- a/studio/components/interfaces/Billing/ProUpgrade.tsx+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx@@ -13,6 +13,7 @@ import {PaymentSummaryPanel,ComputeSizeSelection,PITRDurationSelection,+ CustomDomainSelection,StripeSubscription,AddNewPaymentMethodModal,} from './'@@ -21,7 +22,11 @@ import UpdateSuccess from './UpdateSuccess'import { PaymentMethod, SubscriptionPreview } from './Billing.types'import { formSubscriptionUpdatePayload, getCurrentAddons } from './Billing.utils'import { DatabaseAddon } from './AddOns/AddOns.types'-import { formatComputeSizes, formatPITROptions } from './AddOns/AddOns.utils'+import {+ formatComputeSizes,+ formatCustomDomainOptions,+ formatPITROptions,+} from './AddOns/AddOns.utils'import BackButton from 'components/ui/BackButton'// Do not allow compute size changes for af-south-1@@ -43,12 +48,14 @@ const ProUpgrade: FC<Props> = ({}) => {const { app, ui } = useStore()const router = useRouter()+ const isCustomDomainsEnabled = useFlag('customDomains')const isPITRSelfServeEnabled = useFlag('pitrSelfServe')const { addons } = productsconst computeSizes = formatComputeSizes(addons)const pitrDurationOptions = formatPITROptions(addons)- const { currentComputeSize, currentPITRDuration } = getCurrentAddons(currentSubscription, addons)+ const customDomainOptions = formatCustomDomainOptions(addons)+ const currentAddons = getCurrentAddons(currentSubscription, addons)const projectId = ui.selectedProject?.id ?? -1const projectRef = ui.selectedProject?.ref@@ -67,10 +74,27 @@ const ProUpgrade: FC<Props> = ({const [showAddPaymentMethodModal, setShowAddPaymentMethodModal] = useState(false)const [showSpendCapHelperModal, setShowSpendCapHelperModal] = useState(false)+ // [Joshen TODO] Ideally we just have a state to hold all the add ons selection, rather than individual+ // Even better if we can just use the <Form> component to handle all of these. Mainly to reduce the amount+ // of unnecessary state management on this complex page.+ const [selectedComputeSize, setSelectedComputeSize] = useState<DatabaseAddon>(+ currentAddons.computeSize+ )+ const [selectedPITRDuration, setSelectedPITRDuration] = useState<DatabaseAddon>(+ currentAddons.pitrDuration+ )+ const [selectedCustomDomainOption, setSelectedCustomDomainOption] = useState<DatabaseAddon>(+ currentAddons.customDomains+ )++ // [Joshen] Scaffolded here+ const selectedAddons = {+ computeSize: selectedComputeSize,+ pitrDuration: selectedPITRDuration,+ customDomains: selectedCustomDomainOption,+ }+const [selectedPaymentMethodId, setSelectedPaymentMethodId] = useState<string>('')- const [selectedComputeSize, setSelectedComputeSize] = useState<DatabaseAddon>(currentComputeSize)- const [selectedPITRDuration, setSelectedPITRDuration] =- useState<DatabaseAddon>(currentPITRDuration)const [subscriptionPreview, setSubscriptionPreview] = useState<SubscriptionPreview>()const selectedTier = isSpendCapEnabled@@ -81,7 +105,7 @@ const ProUpgrade: FC<Props> = ({currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PRO ||currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG- const isChangingComputeSize = currentComputeSize?.id !== selectedComputeSize.id+ const isChangingComputeSize = currentAddons.computeSize?.id !== selectedAddons.computeSize.iduseEffect(() => {if (!isLoadingPaymentMethods && paymentMethods && paymentMethods.length > 0) {@@ -91,15 +115,14 @@ const ProUpgrade: FC<Props> = ({useEffect(() => {getSubscriptionPreview()- }, [selectedComputeSize, selectedPITRDuration, isSpendCapEnabled])+ }, [selectedComputeSize, selectedPITRDuration, selectedCustomDomainOption, isSpendCapEnabled])const getSubscriptionPreview = async () => {if (!selectedTier) returnconst payload = formSubscriptionUpdatePayload(selectedTier,- selectedComputeSize,- selectedPITRDuration,+ selectedAddons,selectedPaymentMethodId,projectRegion)@@ -119,8 +142,7 @@ const ProUpgrade: FC<Props> = ({const onConfirmPayment = async () => {const payload = formSubscriptionUpdatePayload(selectedTier,- selectedComputeSize,- selectedPITRDuration,+ selectedAddons,selectedPaymentMethodId,projectRegion)@@ -220,15 +242,28 @@ const ProUpgrade: FC<Props> = ({</div>{projectRegion !== 'af-south-1' && (<>+ {isCustomDomainsEnabled && customDomainOptions.length > 0 && (+ <>+ <Divider light />+ <CustomDomainSelection+ options={customDomainOptions}+ currentOption={+ isManagingProSubscription ? currentAddons.customDomains : undefined+ }+ selectedOption={selectedAddons.customDomains}+ onSelectOption={setSelectedCustomDomainOption}+ />+ </>+ )}{isPITRSelfServeEnabled && pitrDurationOptions.length > 0 && (<><Divider light /><PITRDurationSelectionpitrDurationOptions={pitrDurationOptions}currentPitrDuration={- isManagingProSubscription ? currentPITRDuration : undefined+ isManagingProSubscription ? currentAddons.pitrDuration : undefined}- selectedPitrDuration={selectedPITRDuration}+ selectedPitrDuration={selectedAddons.pitrDuration}onSelectOption={setSelectedPITRDuration}/></>@@ -236,8 +271,8 @@ const ProUpgrade: FC<Props> = ({<Divider light /><ComputeSizeSelectioncomputeSizes={computeSizes || []}- currentComputeSize={currentComputeSize}- selectedComputeSize={selectedComputeSize}+ currentComputeSize={currentAddons.computeSize}+ selectedComputeSize={selectedAddons.computeSize}onSelectOption={setSelectedComputeSize}/></>@@ -253,12 +288,10 @@ const ProUpgrade: FC<Props> = ({isSpendCapEnabled={isSpendCapEnabled}// Current subscription configuration based on DBcurrentPlan={currentSubscription.tier}- currentComputeSize={currentComputeSize}- currentPITRDuration={currentPITRDuration}+ currentAddons={currentAddons}// Selected subscription configuration based on UIselectedPlan={selectedTier}- selectedComputeSize={selectedComputeSize}- selectedPITRDuration={selectedPITRDuration}+ selectedAddons={selectedAddons}paymentMethods={paymentMethods}isLoadingPaymentMethods={isLoadingPaymentMethods}selectedPaymentMethod={selectedPaymentMethodId}diff --git a/studio/components/interfaces/Billing/index.ts b/studio/components/interfaces/Billing/index.tsindex afcd29a86aa..ece846df89b 100644--- a/studio/components/interfaces/Billing/index.ts+++ b/studio/components/interfaces/Billing/index.ts@@ -7,6 +7,7 @@ import ExitSurvey from './ExitSurvey/ExitSurvey'import PaymentSummaryPanel from './PaymentSummaryPanel/PaymentSummaryPanel'import ComputeSizeSelection from './AddOns/ComputeSizeSelection'import PITRDurationSelection from './AddOns/PITRDurationSelection'+import CustomDomainSelection from './AddOns/CustomDomainSelection'import AddNewPaymentMethodModal from './AddNewPaymentMethodModal/AddNewPaymentMethodModal'import UpdateSuccess from './UpdateSuccess'@@ -22,6 +23,7 @@ export {PaymentSummaryPanel,ComputeSizeSelection,PITRDurationSelection,+ CustomDomainSelection,AddNewPaymentMethodModal,UpdateSuccess,Invoices,