The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Implement EnterpriseUpdate page
Joshen Limb78f72b14349
diff --git a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsxindex dd7307bdda0..e3940c04895 100644--- a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx+++ b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx@@ -8,11 +8,17 @@ import DisabledWarningDueToIncident from 'components/ui/DisabledWarningDueToInciinterface Props {computeSizes: any[]+ currentComputeSize?: anyselectedComputeSize: anyonSelectOption: (option: any) => void}-const ComputeSizeSelection: FC<Props> = ({ computeSizes, selectedComputeSize, onSelectOption }) => {+const ComputeSizeSelection: FC<Props> = ({+ computeSizes,+ currentComputeSize,+ selectedComputeSize,+ onSelectOption,+}) => {const { ui } = useStore()const projectRef = ui.selectedProjectRefconst addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')@@ -39,7 +45,15 @@ const ComputeSizeSelection: FC<Props> = ({ computeSizes, selectedComputeSize, onhiddenkey={option.id}align="vertical"- label={option.name}+ // @ts-ignore+ label={+ <div className="flex items-center space-x-4">+ <p>{option.name}</p>+ {currentComputeSize?.id === option.id && (+ <Badge color="brand">Current selection</Badge>+ )}+ </div>+ }// @ts-ignoredescription={<div>diff --git a/studio/components/interfaces/Billing/Billing.utils.ts b/studio/components/interfaces/Billing/Billing.utils.tsindex fd4f3e6cb9c..44dca5e310c 100644--- a/studio/components/interfaces/Billing/Billing.utils.ts+++ b/studio/components/interfaces/Billing/Billing.utils.ts@@ -6,3 +6,21 @@ export const getProductPrice = (product: any) => {: product.prices[0]return price}++export const formSubscriptionUpdatePayload = (+ selectedTier: any,+ selectedComputeSize: any,+ selectedPaymentMethod: string,+ region: string+) => {+ const defaultPrice = selectedTier ? getProductPrice(selectedTier) : undefined+ const addons =+ region === 'af-south-1' || !selectedComputeSize.id ? [] : [selectedComputeSize.prices[0].id]+ const proration_date = Math.floor(Date.now() / 1000)+ return {+ ...(defaultPrice && { tier: defaultPrice.id }),+ addons,+ proration_date,+ payment_method: selectedPaymentMethod,+ }+}diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsxnew file mode 100644index 00000000000..6d40e0f6994--- /dev/null+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx@@ -0,0 +1,217 @@+import { FC, useState, useEffect } from 'react'+import { useRouter } from 'next/router'+import { Transition } from '@headlessui/react'++import { useStore } 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 { formatComputeSizes } from './AddOns/AddOns.utils'+import {+ AddNewPaymentMethodModal,+ ComputeSizeSelection,+ StripeSubscription,+ PaymentSummaryPanel,+ UpdateSuccess,+} from './'+import { SubscriptionPreview } from './Billing.types'+import { formSubscriptionUpdatePayload } from './Billing.utils'++interface Props {+ products: { tiers: any[]; addons: any[] }+ paymentMethods?: any[]+ currentSubscription: StripeSubscription+ isLoadingPaymentMethods: boolean+}++const EnterpriseUpdate: FC<Props> = ({+ products,+ paymentMethods,+ currentSubscription,+ isLoadingPaymentMethods,+}) => {+ const { app, ui } = useStore()+ const router = useRouter()++ const projectId = ui.selectedProject?.id ?? -1+ const projectRef = ui.selectedProject?.ref ?? 'default'+ const projectRegion = ui.selectedProject?.region ?? ''++ const { addons } = products+ const computeSizes = formatComputeSizes(addons)+ const currentComputeSize =+ computeSizes.find((option: any) => option.id === currentSubscription?.addons[0]?.prod_id) ||+ computeSizes.find((option: any) => option.metadata.supabase_prod_id === 'addon_instance_micro')++ const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<any>()+ const [selectedComputeSize, setSelectedComputeSize] = useState<any>(currentComputeSize)+ const [subscriptionPreview, setSubscriptionPreview] = useState<SubscriptionPreview>()++ const [isRefreshingPreview, setIsRefreshingPreview] = useState(false)+ const [isSubmitting, setIsSubmitting] = useState(false)+ const [isSuccessful, setIsSuccessful] = useState(false)+ const [showAddPaymentMethodModal, setShowAddPaymentMethodModal] = useState(false)++ const isChangingComputeSize = currentComputeSize?.id !== selectedComputeSize.id++ useEffect(() => {+ getSubscriptionPreview()+ }, [selectedComputeSize])++ useEffect(() => {+ if (!isLoadingPaymentMethods && paymentMethods && paymentMethods.length > 0) {+ setSelectedPaymentMethod(paymentMethods[0].id)+ }+ }, [isLoadingPaymentMethods, paymentMethods])++ const getSubscriptionPreview = async () => {+ // For enterprise, only tier will be fixed based on current subscription+ // Only allow add-ons changing+ const payload = {+ ...formSubscriptionUpdatePayload(+ null,+ selectedComputeSize,+ selectedPaymentMethod,+ projectRegion+ ),+ tier: currentSubscription.tier.price_id,+ }++ setIsRefreshingPreview(true)+ const preview = await post(`${API_URL}/projects/${projectRef}/subscription/preview`, payload)+ if (preview.error) {+ ui.setNotification({+ category: 'error',+ message: `Failed to fetch subscription preview: ${preview.error.message}`,+ })+ }+ setSubscriptionPreview(preview)+ setIsRefreshingPreview(false)+ }++ // Last todo to support enterprise billing on dashboard + E2E test+ const onConfirmPayment = async () => {+ const payload = {+ ...formSubscriptionUpdatePayload(+ null,+ selectedComputeSize,+ selectedPaymentMethod,+ projectRegion+ ),+ tier: currentSubscription.tier.price_id,+ }++ setIsSubmitting(true)+ const res = await patch(`${API_URL}/projects/${projectRef}/subscription`, payload)+ if (res?.error) {+ ui.setNotification({+ category: 'error',+ message: `Failed to update subscription: ${res?.error?.message}`,+ })+ } else {+ if (isChangingComputeSize) {+ app.onProjectStatusUpdated(projectId, PROJECT_STATUS.RESTORING)+ ui.setNotification({+ category: 'success',+ message:+ 'Your project has been updated and is currently restarting to update its instance size',+ duration: 8000,+ })+ router.push(`/project/${projectRef}`)+ } else {+ setIsSuccessful(true)+ }+ }+ setIsSubmitting(false)+ }++ if (!isSubmitting && isSuccessful) {+ return (+ <UpdateSuccess+ projectRef={projectRef || ''}+ title="Your project has been updated!"+ message="Let us know if you have any feedback at [email protected]."+ />+ )+ }++ return (+ <>+ <Transition+ show+ enter="transition ease-out duration-300"+ enterFrom="transform opacity-0 translate-x-10"+ enterTo="transform opacity-100 translate-x-0"+ className="flex w-full items-start justify-between"+ >+ <div className="2xl:min-w-5xl mx-auto mt-10">+ <div className="relative space-y-4 px-5">+ <div className="space-y-8">+ <h4 className="text-scale-900 text-lg">Change your project's subscription</h4>+ <div+ className="space-y-8 overflow-scroll pb-8"+ style={{ height: 'calc(100vh - 9rem - 57px)' }}+ >+ <h3 className="text-xl">+ Managing your <span className="text-brand-900">Enterprise</span> plan+ </h3>+ <div+ className={[+ 'bg-panel-body-light dark:bg-panel-body-dark border-panel-border-light border-panel-border-dark',+ 'flex max-w-[600px] items-center justify-between gap-16 rounded border px-6 py-4 drop-shadow-sm',+ ].join(' ')}+ >+ <p>+ If you'd like to change your subscription away from enterprise, please reach out+ to <span className="text-brand-900">[email protected]</span> with your+ request.+ </p>+ </div>+ {projectRegion !== 'af-south-1' && (+ <>+ <Divider light />+ <ComputeSizeSelection+ computeSizes={computeSizes || []}+ currentComputeSize={currentComputeSize}+ selectedComputeSize={selectedComputeSize}+ onSelectOption={setSelectedComputeSize}+ />+ </>+ )}+ </div>+ </div>+ </div>+ </div>+ <div className="w-[32rem]">+ <PaymentSummaryPanel+ isSpendCapEnabled={true}+ isSubmitting={isSubmitting}+ isRefreshingPreview={isRefreshingPreview}+ subscriptionPreview={subscriptionPreview}+ currentPlan={currentSubscription.tier}+ currentComputeSize={currentComputeSize}+ selectedComputeSize={selectedComputeSize}+ paymentMethods={paymentMethods}+ isLoadingPaymentMethods={isLoadingPaymentMethods}+ selectedPaymentMethod={selectedPaymentMethod}+ onSelectPaymentMethod={setSelectedPaymentMethod}+ onSelectAddNewPaymentMethod={() => {+ setShowAddPaymentMethodModal(true)+ }}+ onConfirmPayment={onConfirmPayment}+ />+ </div>+ </Transition>++ <AddNewPaymentMethodModal+ visible={showAddPaymentMethodModal}+ returnUrl={`${getURL()}/project/${projectRef}/settings/billing/update/pro`}+ onCancel={() => setShowAddPaymentMethodModal(false)}+ />+ </>+ )+}++export default EnterpriseUpdatediff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsxindex 58706c93761..a198cf47dbb 100644--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx@@ -11,7 +11,7 @@ import {} from '@supabase/ui'import { useStore } from 'hooks'-import { STRIPE_PRODUCT_IDS } from 'lib/constants'+import { PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'import { SubscriptionPreview } from '../Billing.types'import { getProductPrice } from '../Billing.utils'import PaymentTotal from './PaymentTotal'@@ -61,12 +61,19 @@ const PaymentSummaryPanel: FC<Props> = ({const projectRegion = ui.selectedProject?.regionconst [showConfirmModal, setShowConfirmModal] = useState(false)+ const isEnterprise = currentPlan.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEconst isChangingPlan =- (currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && currentPlan.prod_id !== selectedPlan?.id) ||+ (currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG &&+ selectedPlan &&+ 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 hasChangesToPlan = subscriptionPreview?.has_changes ?? false++ // If it's enterprise we only only changing of add-ons+ const hasChangesToPlan = isEnterprise+ ? isChangingComputeSize+ : subscriptionPreview?.has_changes ?? falseconst getPlanName = (plan: any) => {if (plan.prod_id === STRIPE_PRODUCT_IDS.PAYG || plan.id === STRIPE_PRODUCT_IDS.PAYG) {diff --git a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsxsimilarity index 69%rename from studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsxrename to studio/components/interfaces/Billing/ProUpgrade.tsxindex a7492312d4f..263542c4aaa 100644--- a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx@@ -13,12 +13,12 @@ import {ComputeSizeSelection,StripeSubscription,AddNewPaymentMethodModal,-} from '..'+} from './'import { STRIPE_PRODUCT_IDS } from 'lib/constants'-import { SubscriptionPreview } from '../Billing.types'-import UpdateSuccess from '../UpdateSuccess'-import { formatComputeSizes } from '../AddOns/AddOns.utils'-import { formSubscriptionUpdatePayload } from './ProUpgrade.utils'+import { SubscriptionPreview } from './Billing.types'+import { formSubscriptionUpdatePayload } from './Billing.utils'+import UpdateSuccess from './UpdateSuccess'+import { formatComputeSizes } from './AddOns/AddOns.utils'import BackButton from 'components/ui/BackButton'// Do not allow compute size changes for af-south-1@@ -89,10 +89,6 @@ const ProUpgrade: FC<Props> = ({getSubscriptionPreview()}, [selectedComputeSize, isSpendCapEnabled])- const onSelectComputeSizeOption = (option: any) => {- setSelectedComputeSize(option)- }-const getSubscriptionPreview = async () => {if (!selectedTier) return@@ -166,92 +162,93 @@ const ProUpgrade: FC<Props> = ({enterTo="transform opacity-100 translate-x-0"className="flex w-full items-start justify-between">- <>- <div className="2xl:min-w-5xl mx-auto mt-10">- <div className="relative space-y-4 px-5">- <BackButton onClick={() => onSelectBack()} />- <div className="space-y-8">- <h4 className="text-scale-900 text-lg">Change your project's subscription</h4>- <div- className="space-y-8 overflow-scroll pb-8"- style={{ height: 'calc(100vh - 9rem - 57px)' }}- >- <div className="space-y-2">- {!isManagingProSubscription ? (- <>- <h3 className="text-xl">- Welcome to <span className="text-brand-900">Pro</span>- </h3>- <p className="text-scale-1100 text-base">- Your new subscription will begin immediately after payment- </p>- </>- ) : (- <>- <h3 className="text-3xl">- Managing your <span className="text-brand-900">Pro</span> plan- </h3>- <p className="text-scale-1100 text-base">- Your billing cycle will reset after payment- </p>- </>- )}- </div>- <div className="bg-panel-body-light dark:bg-panel-body-dark border-panel-border-light border-panel-border-dark flex items-center justify-between gap-16 rounded border px-6 py-4 drop-shadow-sm">- <div>- <div className="flex items-center space-x-2">- <p>Enable spend cap</p>- <IconHelpCircle- size={16}- strokeWidth={1.5}- className="cursor-pointer opacity-50 transition hover:opacity-100"- onClick={() => setShowSpendCapHelperModal(true)}- />- </div>- <p className="text-scale-1100 text-sm">- If enabled, additional resources will not be charged on a per-usage basis+ <div className="2xl:min-w-5xl mx-auto mt-10">+ <div className="relative space-y-4 px-5">+ <BackButton onClick={() => onSelectBack()} />+ <div className="space-y-8">+ <h4 className="text-scale-900 text-lg">Change your project's subscription</h4>+ <div+ className="space-y-8 overflow-scroll pb-8"+ style={{ height: 'calc(100vh - 9rem - 57px)' }}+ >+ <div className="space-y-2">+ {!isManagingProSubscription ? (+ <>+ <h3 className="text-xl">+ Welcome to <span className="text-brand-900">Pro</span>+ </h3>+ <p className="text-scale-1100 text-base">+ Your new subscription will begin immediately after payment</p>- </div>- <Toggle- checked={isSpendCapEnabled}- onChange={() => setIsSpendCapEnabled(!isSpendCapEnabled)}- />- </div>- {projectRegion !== 'af-south-1' && (+ </>+ ) : (<>- <Divider light />- <ComputeSizeSelection- computeSizes={computeSizes || []}- selectedComputeSize={selectedComputeSize}- onSelectOption={onSelectComputeSizeOption}- />+ <h3 className="text-3xl">+ Managing your <span className="text-brand-900">Pro</span> plan+ </h3>+ <p className="text-scale-1100 text-base">+ Your billing cycle will reset after payment+ </p></>)}</div>+ <div className="bg-panel-body-light dark:bg-panel-body-dark border-panel-border-light border-panel-border-dark flex items-center justify-between gap-16 rounded border px-6 py-4 drop-shadow-sm">+ <div>+ <div className="flex items-center space-x-2">+ <p>Enable spend cap</p>+ <IconHelpCircle+ size={16}+ strokeWidth={1.5}+ className="cursor-pointer opacity-50 transition hover:opacity-100"+ onClick={() => setShowSpendCapHelperModal(true)}+ />+ </div>+ <p className="text-scale-1100 text-sm">+ If enabled, additional resources will not be charged on a per-usage basis+ </p>+ </div>+ <Toggle+ checked={isSpendCapEnabled}+ onChange={() => setIsSpendCapEnabled(!isSpendCapEnabled)}+ />+ </div>+ {projectRegion !== 'af-south-1' && (+ <>+ <Divider light />+ <ComputeSizeSelection+ computeSizes={computeSizes || []}+ currentComputeSize={+ isManagingProSubscription ? currentComputeSize : undefined+ }+ selectedComputeSize={selectedComputeSize}+ onSelectOption={setSelectedComputeSize}+ />+ </>+ )}</div></div></div>- <div className="w-[32rem]">- <PaymentSummaryPanel- isRefreshingPreview={isRefreshingPreview}- subscriptionPreview={subscriptionPreview}- currentPlan={currentSubscription.tier}- selectedPlan={selectedTier}- isSpendCapEnabled={isSpendCapEnabled}- currentComputeSize={currentComputeSize}- selectedComputeSize={selectedComputeSize}- paymentMethods={paymentMethods}- isLoadingPaymentMethods={isLoadingPaymentMethods}- selectedPaymentMethod={selectedPaymentMethod}- onSelectPaymentMethod={setSelectedPaymentMethod}- onSelectAddNewPaymentMethod={() => {- setShowAddPaymentMethodModal(true)- }}- onConfirmPayment={onConfirmPayment}- isSubmitting={isSubmitting}- />- </div>- </>+ </div>+ <div className="w-[32rem]">+ <PaymentSummaryPanel+ isRefreshingPreview={isRefreshingPreview}+ subscriptionPreview={subscriptionPreview}+ currentPlan={currentSubscription.tier}+ selectedPlan={selectedTier}+ isSpendCapEnabled={isSpendCapEnabled}+ currentComputeSize={currentComputeSize}+ selectedComputeSize={selectedComputeSize}+ paymentMethods={paymentMethods}+ isLoadingPaymentMethods={isLoadingPaymentMethods}+ selectedPaymentMethod={selectedPaymentMethod}+ onSelectPaymentMethod={setSelectedPaymentMethod}+ onSelectAddNewPaymentMethod={() => {+ setShowAddPaymentMethodModal(true)+ }}+ onConfirmPayment={onConfirmPayment}+ isSubmitting={isSubmitting}+ />+ </div></Transition><AddNewPaymentMethodModaldiff --git a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts b/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.tsdeleted file mode 100644index ca22357c6b9..00000000000--- a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts+++ /dev/null@@ -1,19 +0,0 @@-import { getProductPrice } from '../Billing.utils'--export const formSubscriptionUpdatePayload = (- selectedTier: any,- selectedComputeSize: any,- selectedPaymentMethod: string,- region: string-) => {- const defaultPrice = getProductPrice(selectedTier)- const addons =- region === 'af-south-1' || !selectedComputeSize.id ? [] : [selectedComputeSize.prices[0].id]- const proration_date = Math.floor(Date.now() / 1000)- return {- tier: defaultPrice.id,- addons,- proration_date,- payment_method: selectedPaymentMethod,- }-}diff --git a/studio/components/interfaces/Billing/Subscription/Subscription.tsx b/studio/components/interfaces/Billing/Subscription/Subscription.tsxindex a6e7486aa73..470f6625baa 100644--- a/studio/components/interfaces/Billing/Subscription/Subscription.tsx+++ b/studio/components/interfaces/Billing/Subscription/Subscription.tsx@@ -5,7 +5,7 @@ import { useRouter } from 'next/router'import { Loading, Button } from '@supabase/ui'import { formatBytes } from 'lib/helpers'-import { STRIPE_PRODUCT_IDS } from 'lib/constants'+import { PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'import { useStore, useFlag } from 'hooks'import CostBreakdownRow from './CostBreakdownRow'import { StripeSubscription } from './Subscription.types'@@ -38,9 +38,10 @@ const Subscription: FC<Props> = ({const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')const isPayg = subscription?.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG+ const isEnterprise = subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE+const addOns = subscription?.addons ?? []const paid = subscription && subscription.tier.unit_amount > 0-const basePlanCost = subscription?.tier.unit_amount / 100const deriveTotalCost = (): number => {@@ -63,13 +64,25 @@ const Subscription: FC<Props> = ({<h3 className="mb-0 text-xl">{subscription?.tier.name ?? '-'}</h3></div><div className="flex flex-col items-end space-y-2">- <Button- disabled={!isOrgOwner || projectUpdateDisabled}- onClick={() => router.push(`/project/${project.ref}/settings/billing/update`)}- type="primary"- >- Change subscription- </Button>+ {isEnterprise ? (+ <Button+ disabled={!isOrgOwner || projectUpdateDisabled}+ onClick={() =>+ router.push(`/project/${project.ref}/settings/billing/update/enterprise`)+ }+ type="primary"+ >+ Change add-ons+ </Button>+ ) : (+ <Button+ disabled={!isOrgOwner || projectUpdateDisabled}+ onClick={() => router.push(`/project/${project.ref}/settings/billing/update`)}+ type="primary"+ >+ Change subscription+ </Button>+ )}{!isOrgOwner ? (<p className="text-scale-1100 text-xs">Only the organization owner can amend subscriptionsdiff --git a/studio/components/interfaces/Billing/Subscription/Subscription.types.ts b/studio/components/interfaces/Billing/Subscription/Subscription.types.tsindex ed09a01a208..92efce4c65c 100644--- a/studio/components/interfaces/Billing/Subscription/Subscription.types.ts+++ b/studio/components/interfaces/Billing/Subscription/Subscription.types.ts@@ -11,6 +11,7 @@ export interface StripeSubscription {export interface StripeProduct {name: stringprod_id: string+ price_id?: stringunit_amount: numbersupabase_prod_id: string}diff --git a/studio/components/interfaces/Billing/index.ts b/studio/components/interfaces/Billing/index.tsindex 786c5c24e39..7dd9806e708 100644--- a/studio/components/interfaces/Billing/index.ts+++ b/studio/components/interfaces/Billing/index.ts@@ -2,7 +2,7 @@ import PAYGUsage from './PAYGUsage/PAYGUsage'import Subscription from './Subscription/Subscription'import PlanSelection from './PlanSelection/PlanSelection'-import ProUpgrade from './ProUpgrade/ProUpgrade'+import ProUpgrade from './ProUpgrade'import ExitSurvey from './ExitSurvey/ExitSurvey'import PaymentSummaryPanel from './PaymentSummaryPanel/PaymentSummaryPanel'import ComputeSizeSelection from './AddOns/ComputeSizeSelection'diff --git a/studio/lib/constants/infrastructure.ts b/studio/lib/constants/infrastructure.tsindex c1911762535..657c1d96381 100644--- a/studio/lib/constants/infrastructure.ts+++ b/studio/lib/constants/infrastructure.ts@@ -29,6 +29,7 @@ export const PRICING_TIER_PRODUCT_IDS = {FREE: 'tier_free',PRO: 'tier_pro',PAYG: 'tier_payg',+ ENTERPRISE: 'tier_enterprise',}export const PRICING_TIER_FREE_KEY = 'FREE'diff --git a/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsxnew file mode 100644index 00000000000..a9d59135753--- /dev/null+++ b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx@@ -0,0 +1,108 @@+import { useState, useEffect } from 'react'+import { observer } from 'mobx-react-lite'+import { useRouter } from 'next/router'++import { useStore, useFlag } from 'hooks'+import { NextPageWithLayout } from 'types'+import { API_URL } from 'lib/constants'+import { get } from 'lib/common/fetch'++import Connecting from 'components/ui/Loading/Loading'+import { BillingLayout } from 'components/layouts'+import { StripeSubscription } from 'components/interfaces/Billing'+import EnterpriseUpdate from 'components/interfaces/Billing/EnterpriseUpdate'++const BillingUpdateEnterprise: NextPageWithLayout = () => {+ const { ui } = useStore()+ const router = useRouter()++ const projectRef = ui.selectedProject?.ref+ const orgSlug = ui.selectedOrganization?.slug+ const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')++ const [isLoadingPaymentMethods, setIsLoadingPaymentMethods] = useState(false)+ const [subscription, setSubscription] = useState<StripeSubscription>()+ const [products, setProducts] = useState<{ tiers: any[]; addons: any[] }>()+ const [paymentMethods, setPaymentMethods] = useState<any>()++ useEffect(() => {+ if (projectUpdateDisabled) {+ router.push(`/project/${projectRef}/settings/billing/update`)+ } else if (projectRef) {+ getStripeProducts()+ getSubscription()+ }+ }, [projectRef])++ useEffect(() => {+ if (orgSlug) {+ getPaymentMethods()+ }+ }, [orgSlug])++ const getStripeProducts = async () => {+ try {+ const products = await get(`${API_URL}/stripe/products`)+ setProducts(products)+ } catch (error: any) {+ ui.setNotification({+ error,+ category: 'error',+ message: `Failed to get products: ${error.message}`,+ })+ }+ }++ const getPaymentMethods = async () => {+ const orgSlug = ui.selectedOrganization?.slug ?? ''+ try {+ setIsLoadingPaymentMethods(true)+ const { data: paymentMethods, error } = await get(+ `${API_URL}/organizations/${orgSlug}/payments`+ )+ if (error) throw error+ setIsLoadingPaymentMethods(false)+ setPaymentMethods(paymentMethods)+ } catch (error: any) {+ ui.setNotification({+ error,+ category: 'error',+ message: `Failed to get available payment methods: ${error.message}`,+ })+ }+ }++ const getSubscription = async () => {+ try {+ if (!ui.selectedProject?.subscription_id) {+ throw new Error('Unable to get subscription ID of project')+ }++ const subscription = await get(`${API_URL}/projects/${projectRef}/subscription`)+ if (subscription.error) throw subscription.error++ setSubscription(subscription)+ } catch (error: any) {+ ui.setNotification({+ error,+ category: 'error',+ message: `Failed to get subscription: ${error.message}`,+ })+ }+ }++ if (!products || !subscription) return <Connecting />++ return (+ <EnterpriseUpdate+ products={products}+ currentSubscription={subscription}+ isLoadingPaymentMethods={isLoadingPaymentMethods}+ paymentMethods={paymentMethods || []}+ />+ )+}++BillingUpdateEnterprise.getLayout = (page) => <BillingLayout>{page}</BillingLayout>++export default observer(BillingUpdateEnterprise)diff --git a/studio/pages/project/[ref]/settings/billing/update/free.tsx b/studio/pages/project/[ref]/settings/billing/update/free.tsxindex b48a04e6ce8..0410229614d 100644--- a/studio/pages/project/[ref]/settings/billing/update/free.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/free.tsx@@ -5,10 +5,11 @@ import { useRouter } from 'next/router'import { NextPageWithLayout } from 'types'import { useStore, useFlag } from 'hooks'import { get } from 'lib/common/fetch'-import { API_URL, STRIPE_PRODUCT_IDS } from 'lib/constants'+import { API_URL, PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'import { BillingLayout } from 'components/layouts'import { ExitSurvey, StripeSubscription } from 'components/interfaces/Billing'+import Connecting from 'components/ui/Loading/Loading'const BillingUpdateFree: NextPageWithLayout = () => {const { ui } = useStore()@@ -19,7 +20,9 @@ const BillingUpdateFree: NextPageWithLayout = () => {const [products, setProducts] = useState<{ tiers: any[]; addons: any[] }>()const [subscription, setSubscription] = useState<StripeSubscription>()- const [isLoadingProducts, setIsLoadingProducts] = useState(false)++ const isEnterprise =+ subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEuseEffect(() => {if (projectUpdateDisabled) {@@ -30,12 +33,16 @@ const BillingUpdateFree: NextPageWithLayout = () => {}}, [projectRef])+ useEffect(() => {+ if (isEnterprise) {+ router.push(`/project/${projectRef}/settings/billing/update/enterprise`)+ }+ }, [subscription])+const getStripeProducts = async () => {try {- setIsLoadingProducts(true)const products = await get(`${API_URL}/stripe/products`)setProducts(products)- setIsLoadingProducts(false)} catch (error: any) {ui.setNotification({error,@@ -65,6 +72,13 @@ const BillingUpdateFree: NextPageWithLayout = () => {const freeTier = products?.tiers.find((tier: any) => tier.id === STRIPE_PRODUCT_IDS.FREE)+ if (isEnterprise)+ return (+ <div className="flex h-full w-full items-center justify-center">+ <Connecting />+ </div>+ )+return (<div className="mx-auto my-10 max-w-5xl"><ExitSurveydiff --git a/studio/pages/project/[ref]/settings/billing/update/index.tsx b/studio/pages/project/[ref]/settings/billing/update/index.tsxindex 2f30af53b9a..00d87ab74e0 100644--- a/studio/pages/project/[ref]/settings/billing/update/index.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/index.tsx@@ -5,7 +5,12 @@ import { Button, Modal } from '@supabase/ui'import { useStore, useSubscriptionStats } from 'hooks'import { get } from 'lib/common/fetch'-import { API_URL, DEFAULT_FREE_PROJECTS_LIMIT, STRIPE_PRODUCT_IDS } from 'lib/constants'+import {+ API_URL,+ DEFAULT_FREE_PROJECTS_LIMIT,+ PRICING_TIER_PRODUCT_IDS,+ STRIPE_PRODUCT_IDS,+} from 'lib/constants'import { BillingLayout } from 'components/layouts'import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'@@ -30,6 +35,9 @@ const BillingUpdate: NextPageWithLayout = () => {const [subscription, setSubscription] = useState<StripeSubscription>()const [selectedPlan, setSelectedPlan] = useState<any>()+ const isEnterprise =+ subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE+useEffect(() => {if (projectRef) {getStripeProducts()@@ -37,6 +45,12 @@ const BillingUpdate: NextPageWithLayout = () => {}}, [projectRef])+ useEffect(() => {+ if (isEnterprise) {+ router.push(`/project/${projectRef}/settings/billing/update/enterprise`)+ }+ }, [subscription])+// [Joshen] Perhaps we shift this fetch into the global mobx tree// Since all the pages require this data, makes more sense to load it once at the layoutconst getStripeProducts = async () => {@@ -92,7 +106,7 @@ const BillingUpdate: NextPageWithLayout = () => {}}- if (isLoadingProducts) {+ if (isLoadingProducts || isEnterprise) {return (<div className="flex h-full w-full items-center justify-center"><Connecting />diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsxindex 288f739c43a..478a9015993 100644--- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx@@ -4,7 +4,7 @@ import { useRouter } from 'next/router'import { useStore, useFlag } from 'hooks'import { get } from 'lib/common/fetch'-import { API_URL } from 'lib/constants'+import { API_URL, PRICING_TIER_PRODUCT_IDS } from 'lib/constants'import { BillingLayout } from 'components/layouts'import Connecting from 'components/ui/Loading/Loading'@@ -28,6 +28,9 @@ const BillingUpdatePro: NextPageWithLayout = () => {const [products, setProducts] = useState<{ tiers: any[]; addons: any[] }>()const [paymentMethods, setPaymentMethods] = useState<any>()+ const isEnterprise =+ subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE+useEffect(() => {// User added a new payment methodif (router.query.setup_intent && router.query.redirect_status) {@@ -50,6 +53,12 @@ const BillingUpdatePro: NextPageWithLayout = () => {}}, [orgSlug])+ useEffect(() => {+ if (isEnterprise) {+ router.push(`/project/${projectRef}/settings/billing/update/enterprise`)+ }+ }, [subscription])+const getStripeProducts = async () => {try {setIsLoadingProducts(true)@@ -102,7 +111,12 @@ const BillingUpdatePro: NextPageWithLayout = () => {}}- if (!products || !subscription) return <Connecting />+ if (!products || !subscription || isEnterprise)+ return (+ <div className="flex h-full w-full items-center justify-center">+ <Connecting />+ </div>+ )return (<ProUpgrade