Skip to content

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

Fix prop error in enterpriseupdate page

Joshen Limdf29cd8bc35a
diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
index 3e3ec309bfd..feaa25d2b09 100644
--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
@@ -5,7 +5,7 @@ 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 { API_URL, PROJECT_STATUS, STRIPE_PRODUCT_IDS } from 'lib/constants'
import HCaptcha from '@hcaptcha/react-hcaptcha'
import Divider from 'components/ui/Divider'
diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
index 0a3d3688a42..c593a008f88 100644
--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
@@ -82,6 +82,9 @@ const PaymentSummaryPanel: FC<Props> = ({
const { ui } = useStore()
const projectRegion = ui.selectedProject?.region
+ // [Joshen] Point of refactor: Current plan can just be currentSubscription.tier
+ // Reduce one unnecessary prop
+
const canUpdatePaymentMethods = checkPermissions(
PermissionAction.BILLING_WRITE,
'stripe.payment_methods'
@@ -90,9 +93,12 @@ const PaymentSummaryPanel: FC<Props> = ({
const [showConfirmModal, setShowConfirmModal] = useState(false)
const selectedPlanCost =
- selectedPlan.prices.find(
- (price: AddonPrice) => price.id === selectedPlan.metadata.default_price_id
- )?.unit_amount ?? 0
+ selectedPlan !== undefined
+ ? selectedPlan.prices.find(
+ (price: AddonPrice) => price.id === selectedPlan.metadata.default_price_id
+ )?.unit_amount ?? 0
+ : currentSubscription?.tier.unit_amount ?? 0
+
const totalSelectedAddonCost = Object.keys(selectedAddons)
.map((productName) => {
const product = (selectedAddons as any)[productName]