Skip to content

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

Update validation for payment summary panel and ensure to refresh meta store when fetching detail after restoration

Joshen Limc63c0a943c74
diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
index 5bad8c2ad9c..6033a2b7c1e 100644
--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx
@@ -19,11 +19,7 @@ import {
UpdateSuccess,
} from './'
import { PaymentMethod, SubscriptionPreview } from './Billing.types'
-import {
- validateSubscriptionUpdatePayload,
- formSubscriptionUpdatePayload,
- getCurrentAddons,
-} from './Billing.utils'
+import { formSubscriptionUpdatePayload, getCurrentAddons } from './Billing.utils'
interface Props {
products: { tiers: any[]; addons: DatabaseAddon[] }
@@ -101,15 +97,6 @@ const EnterpriseUpdate: FC<Props> = ({
// Last todo to support enterprise billing on dashboard + E2E test
const onConfirmPayment = async () => {
- const error = validateSubscriptionUpdatePayload(selectedComputeSize, selectedPITRDuration)
- if (error) {
- return ui.setNotification({
- duration: 4000,
- category: 'error',
- message: error,
- })
- }
-
const payload = {
...formSubscriptionUpdatePayload(
null,
diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
index 634ac3e3ebf..c48366685dd 100644
--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx
@@ -15,7 +15,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { checkPermissions, useFlag, useStore } from 'hooks'
import { PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'
import { SubscriptionPreview } from '../Billing.types'
-import { getProductPrice } from '../Billing.utils'
+import { getProductPrice, validateSubscriptionUpdatePayload } from '../Billing.utils'
import PaymentTotal from './PaymentTotal'
import InformationBox from 'components/ui/InformationBox'
import { DatabaseAddon } from '../AddOns/AddOns.types'
@@ -100,6 +100,19 @@ const PaymentSummaryPanel: FC<Props> = ({
} else return plan.name
}
+ const validateOrder = () => {
+ const error = validateSubscriptionUpdatePayload(selectedComputeSize, selectedPITRDuration)
+ if (error) {
+ return ui.setNotification({
+ duration: 4000,
+ category: 'error',
+ message: error,
+ })
+ } else {
+ isChangingComputeSize ? setShowConfirmModal(true) : onConfirmPayment()
+ }
+ }
+
return (
<>
<div
@@ -315,7 +328,7 @@ const PaymentSummaryPanel: FC<Props> = ({
size="medium"
loading={isSubmitting}
disabled={isSubmitting || isLoadingPaymentMethods || !hasChangesToPlan}
- onClick={() => (isChangingComputeSize ? setShowConfirmModal(true) : onConfirmPayment())}
+ onClick={() => validateOrder()}
>
Confirm payment
</Button>
diff --git a/studio/components/interfaces/Billing/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsx
index ee8ce6280b9..01228f9b264 100644
--- a/studio/components/interfaces/Billing/ProUpgrade.tsx
+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx
@@ -19,11 +19,7 @@ import {
import { STRIPE_PRODUCT_IDS } from 'lib/constants'
import UpdateSuccess from './UpdateSuccess'
import { PaymentMethod, SubscriptionPreview } from './Billing.types'
-import {
- validateSubscriptionUpdatePayload,
- formSubscriptionUpdatePayload,
- getCurrentAddons,
-} from './Billing.utils'
+import { formSubscriptionUpdatePayload, getCurrentAddons } from './Billing.utils'
import { DatabaseAddon } from './AddOns/AddOns.types'
import { formatComputeSizes, formatPITROptions } from './AddOns/AddOns.utils'
import BackButton from 'components/ui/BackButton'
@@ -120,15 +116,6 @@ const ProUpgrade: FC<Props> = ({
}
const onConfirmPayment = async () => {
- const error = validateSubscriptionUpdatePayload(selectedComputeSize, selectedPITRDuration)
- if (error) {
- return ui.setNotification({
- duration: 4000,
- category: 'error',
- message: error,
- })
- }
-
const payload = formSubscriptionUpdatePayload(
selectedTier,
selectedComputeSize,