The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: only redirect when adding CC when needed
Kevin Grüneberg5342505640fc
diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsxindex f8c52edd2eb..64b00d18b5e 100644--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx@@ -14,11 +14,12 @@ interface Props {visible: booleanreturnUrl: stringonCancel: () => void+ onConfirm: () => void}const stripePromise = loadStripe(STRIPE_PUBLIC_KEY)-const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) => {+const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel, onConfirm }) => {const { ui } = useStore()const [intent, setIntent] = useState<any>()@@ -87,6 +88,11 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =return onCancel()}+ const onLocalConfirm = () => {+ setIntent(undefined)+ return onConfirm()+ }+return (// We cant display the hCaptcha in the modal, as the modal auto-closes when clicking the captcha// So we only show the modal if the captcha has been executed successfully (intent loaded)@@ -114,7 +120,11 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =><div className="py-4 space-y-4"><Elements stripe={stripePromise} options={options}>- <AddPaymentMethodForm returnUrl={returnUrl} onCancel={onLocalCancel} />+ <AddPaymentMethodForm+ returnUrl={returnUrl}+ onCancel={onLocalCancel}+ onConfirm={onLocalConfirm}+ /></Elements></div></Modal>diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddPaymentMethodForm.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddPaymentMethodForm.tsxindex 864239450ac..104eae62698 100644--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddPaymentMethodForm.tsx+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddPaymentMethodForm.tsx@@ -6,13 +6,14 @@ import { useStore } from 'hooks'interface Props {returnUrl: stringonCancel: () => void+ onConfirm: () => void}// Stripe docs recommend to use the new SetupIntent flow over// manually creating and attaching payment methods via the API// Small UX annoyance here, that the page will be refreshed-const AddPaymentMethodForm: FC<Props> = ({ returnUrl, onCancel }) => {+const AddPaymentMethodForm: FC<Props> = ({ returnUrl, onCancel, onConfirm }) => {const { ui } = useStore()const stripe = useStripe()const elements = useElements()@@ -36,6 +37,7 @@ const AddPaymentMethodForm: FC<Props> = ({ returnUrl, onCancel }) => {const { error } = await stripe.confirmSetup({elements,+ redirect: 'if_required',confirmParams: { return_url: returnUrl },})@@ -45,6 +47,9 @@ const AddPaymentMethodForm: FC<Props> = ({ returnUrl, onCancel }) => {category: 'error',message: error?.message ?? ' Failed to save card details',})+ } else {+ setIsSaving(false)+ onConfirm()}if (document !== undefined) {diff --git a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx b/studio/components/interfaces/Billing/EnterpriseUpdate.tsxindex 5ac973cd655..0275f33ae61 100644--- a/studio/components/interfaces/Billing/EnterpriseUpdate.tsx+++ b/studio/components/interfaces/Billing/EnterpriseUpdate.tsx@@ -33,6 +33,7 @@ interface Props {paymentMethods?: PaymentMethod[]currentSubscription: StripeSubscriptionisLoadingPaymentMethods: boolean+ onPaymentMethodAdded: () => void}const EnterpriseUpdate: FC<Props> = ({@@ -40,6 +41,7 @@ const EnterpriseUpdate: FC<Props> = ({paymentMethods,currentSubscription,isLoadingPaymentMethods,+ onPaymentMethodAdded,}) => {const { app, ui } = useStore()const router = useRouter()@@ -92,6 +94,11 @@ const EnterpriseUpdate: FC<Props> = ({const isChangingComputeSize = currentAddons.computeSize?.id !== selectedAddons.computeSize.id+ const onLocalPaymentMethodAdded = () => {+ setShowAddPaymentMethodModal(false)+ return onPaymentMethodAdded()+ }+useEffect(() => {getSubscriptionPreview()}, [selectedComputeSize, selectedPITRDuration, selectedCustomDomainOption])@@ -312,6 +319,7 @@ const EnterpriseUpdate: FC<Props> = ({visible={showAddPaymentMethodModal}returnUrl={`${getURL()}/project/${projectRef}/settings/billing/update/pro`}onCancel={() => setShowAddPaymentMethodModal(false)}+ onConfirm={() => onLocalPaymentMethodAdded()}/></>)diff --git a/studio/components/interfaces/Billing/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsxindex 79cabf80039..6ebc73b9181 100644--- a/studio/components/interfaces/Billing/ProUpgrade.tsx+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx@@ -38,6 +38,7 @@ interface Props {paymentMethods?: PaymentMethod[]currentSubscription: StripeSubscriptionisLoadingPaymentMethods: boolean+ onPaymentMethodAdded: () => voidonSelectBack: () => void}@@ -47,6 +48,7 @@ const ProUpgrade: FC<Props> = ({currentSubscription,isLoadingPaymentMethods,onSelectBack,+ onPaymentMethodAdded,}) => {const { app, ui } = useStore()const router = useRouter()@@ -116,6 +118,11 @@ const ProUpgrade: FC<Props> = ({const isChangingComputeSize = currentAddons.computeSize?.id !== selectedAddons.computeSize.id+ const onLocalPaymentMethodAdded = () => {+ setShowAddPaymentMethodModal(false)+ return onPaymentMethodAdded()+ }+useEffect(() => {if (!isLoadingPaymentMethods && paymentMethods && paymentMethods.length > 0) {setSelectedPaymentMethodId(paymentMethods[0].id)@@ -362,6 +369,7 @@ const ProUpgrade: FC<Props> = ({visible={showAddPaymentMethodModal}returnUrl={`${getURL()}/project/${projectRef}/settings/billing/update/pro`}onCancel={() => setShowAddPaymentMethodModal(false)}+ onConfirm={() => onLocalPaymentMethodAdded()}/>{/* Spend caps helper modal */}diff --git a/studio/components/interfaces/Billing/TeamUpgrade.tsx b/studio/components/interfaces/Billing/TeamUpgrade.tsxindex b85d7c15fff..e5902fc7963 100644--- a/studio/components/interfaces/Billing/TeamUpgrade.tsx+++ b/studio/components/interfaces/Billing/TeamUpgrade.tsx@@ -35,6 +35,7 @@ interface TeamUpgradeProps {paymentMethods?: PaymentMethod[]currentSubscription: StripeSubscriptionisLoadingPaymentMethods: boolean+ onPaymentMethodAdded: () => void}const TeamUpgrade = ({@@ -42,6 +43,7 @@ const TeamUpgrade = ({paymentMethods,currentSubscription,isLoadingPaymentMethods,+ onPaymentMethodAdded,}: TeamUpgradeProps) => {const { app, ui } = useStore()const router = useRouter()@@ -160,6 +162,11 @@ const TeamUpgrade = ({return true}+ const onLocalPaymentMethodAdded = () => {+ setShowAddPaymentMethodModal(false)+ return onPaymentMethodAdded()+ }+const onConfirmPayment = async () => {if (!teamTierEnabled) {return ui.setNotification({@@ -328,6 +335,7 @@ const TeamUpgrade = ({visible={showAddPaymentMethodModal}returnUrl={`${getURL()}/project/${projectRef}/settings/billing/update/team`}onCancel={() => setShowAddPaymentMethodModal(false)}+ onConfirm={() => onLocalPaymentMethodAdded()}/></>)diff --git a/studio/components/interfaces/Organization/BillingSettings/BillingSettings.tsx b/studio/components/interfaces/Organization/BillingSettings/BillingSettings.tsxindex ba01a03ef37..0e700116ef2 100644--- a/studio/components/interfaces/Organization/BillingSettings/BillingSettings.tsx+++ b/studio/components/interfaces/Organization/BillingSettings/BillingSettings.tsx@@ -104,6 +104,7 @@ const BillingSettings = () => {paymentMethods={paymentMethods || []}onDefaultMethodUpdated={setCustomer}onPaymentMethodsDeleted={() => getPaymentMethods()}+ onPaymentMethodAdded={() => getPaymentMethods()}/><BillingEmail />diff --git a/studio/components/interfaces/Organization/BillingSettings/PaymentMethods.tsx b/studio/components/interfaces/Organization/BillingSettings/PaymentMethods.tsxindex 9963a537053..c69eea6b4c1 100644--- a/studio/components/interfaces/Organization/BillingSettings/PaymentMethods.tsx+++ b/studio/components/interfaces/Organization/BillingSettings/PaymentMethods.tsx@@ -28,6 +28,7 @@ interface Props {paymentMethods: any[]onDefaultMethodUpdated: (updatedCustomer: any) => voidonPaymentMethodsDeleted: () => void+ onPaymentMethodAdded: () => void}const PaymentMethods: FC<Props> = ({@@ -36,6 +37,7 @@ const PaymentMethods: FC<Props> = ({paymentMethods,onDefaultMethodUpdated,onPaymentMethodsDeleted,+ onPaymentMethodAdded,}) => {const { ui } = useStore()const orgSlug = ui.selectedOrganization?.slug ?? ''@@ -99,6 +101,11 @@ const PaymentMethods: FC<Props> = ({}}+ const onLocalPaymentMethodAdded = () => {+ setShowAddPaymentMethodModal(false)+ return onPaymentMethodAdded()+ }+return (<><div className="space-y-2">@@ -252,6 +259,7 @@ const PaymentMethods: FC<Props> = ({visible={showAddPaymentMethodModal}returnUrl={`${getURL()}/org/${orgSlug}/billing`}onCancel={() => setShowAddPaymentMethodModal(false)}+ onConfirm={() => onLocalPaymentMethodAdded()}/><Modaldiff --git a/studio/components/interfaces/Organization/NewProject/EmptyPaymentMethodWarning.tsx b/studio/components/interfaces/Organization/NewProject/EmptyPaymentMethodWarning.tsxindex 446ec59b174..e11f0317b4f 100644--- a/studio/components/interfaces/Organization/NewProject/EmptyPaymentMethodWarning.tsx+++ b/studio/components/interfaces/Organization/NewProject/EmptyPaymentMethodWarning.tsx@@ -8,12 +8,18 @@ import InformationBox from 'components/ui/InformationBox'import { AddNewPaymentMethodModal } from 'components/interfaces/Billing'const EmptyPaymentMethodWarning = observer(- ({ stripeCustomerId }: { stripeCustomerId: string | undefined }) => {+ ({ onPaymentMethodAdded }: { onPaymentMethodAdded: () => void }) => {const { ui } = useStore()const slug = ui.selectedOrganization?.slugconst [showAddPaymentMethodModal, setShowAddPaymentMethodModal] = useState<boolean>(false)+ const onLocalPaymentMethodAdded = () => {+ setShowAddPaymentMethodModal(false)++ return onPaymentMethodAdded()+ }+return (<div className="mt-4"><InformationBox@@ -37,6 +43,7 @@ const EmptyPaymentMethodWarning = observer(visible={showAddPaymentMethodModal}returnUrl={`${getURL()}/new/${slug}`}onCancel={() => setShowAddPaymentMethodModal(false)}+ onConfirm={() => onLocalPaymentMethodAdded()}/></div>)diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsxindex 919e2b3ea23..8aec44d5a22 100644--- a/studio/pages/new/[slug].tsx+++ b/studio/pages/new/[slug].tsx@@ -112,14 +112,14 @@ const Wizard: NextPageWithLayout = () => {}}, [])- useEffect(() => {- async function getPaymentMethods(slug: string) {- const { data: paymentMethods, error } = await get(`${API_URL}/organizations/${slug}/payments`)- if (!error) {- setPaymentMethods(paymentMethods)- }+ async function getPaymentMethods(slug: string) {+ const { data: paymentMethods, error } = await get(`${API_URL}/organizations/${slug}/payments`)+ if (!error) {+ setPaymentMethods(paymentMethods)}+ }+ useEffect(() => {if (slug) {getPaymentMethods(slug as string)}@@ -147,6 +147,12 @@ const Wizard: NextPageWithLayout = () => {setDbPricingTierKey(value)}+ function onPaymentMethodAdded() {+ if (slug) {+ return getPaymentMethods(slug)+ }+ }+async function checkPasswordStrength(value: any) {const { message, warning, strength } = await passwordStrength(value)setPasswordStrengthScore(strength)@@ -443,7 +449,7 @@ const Wizard: NextPageWithLayout = () => {)}{!isSelectFreeTier && isEmptyPaymentMethod && (- <EmptyPaymentMethodWarning stripeCustomerId={stripeCustomerId} />+ <EmptyPaymentMethodWarning onPaymentMethodAdded={onPaymentMethodAdded} />)}</Panel.Content>)}diff --git a/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsxindex 90c6d4a9c94..07e07e49304 100644--- a/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx@@ -111,6 +111,7 @@ const BillingUpdateEnterprise: NextPageWithLayout = () => {currentSubscription={subscription}isLoadingPaymentMethods={isLoadingPaymentMethods}paymentMethods={paymentMethods || []}+ onPaymentMethodAdded={() => getPaymentMethods()}/>)}diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsxindex a175d3688f1..7884a282b3a 100644--- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx@@ -119,6 +119,7 @@ const BillingUpdatePro: NextPageWithLayout = () => {isLoadingPaymentMethods={isLoadingPaymentMethods}paymentMethods={paymentMethods || []}onSelectBack={() => router.push(`/project/${projectRef}/settings/billing/update`)}+ onPaymentMethodAdded={() => getPaymentMethods()}/>)}diff --git a/studio/pages/project/[ref]/settings/billing/update/team.tsx b/studio/pages/project/[ref]/settings/billing/update/team.tsxindex 316e1bb5976..5907f56e72f 100644--- a/studio/pages/project/[ref]/settings/billing/update/team.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/team.tsx@@ -118,6 +118,7 @@ const BillingUpdateTeam: NextPageWithLayout = () => {currentSubscription={subscription}isLoadingPaymentMethods={isLoadingPaymentMethods}paymentMethods={paymentMethods || []}+ onPaymentMethodAdded={() => getPaymentMethods()}/>)}