The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Clean up billing pages and components
Joshen Limd8273f1ca785
diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsxindex 4b2ec5742cc..be9c46dc57e 100644--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/index.tsx@@ -1,5 +1,5 @@import { FC, useEffect, useState } from 'react'-import { Button, IconLoader, Modal } from '@supabase/ui'+import { IconLoader, Modal } from '@supabase/ui'import { loadStripe } from '@stripe/stripe-js'import { Elements } from '@stripe/react-stripe-js'@@ -21,11 +21,11 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, onCancel }) => {useEffect(() => {if (visible) {- onSelectAddNewPaymentMethod()+ setupIntent()}}, [visible])- const onSelectAddNewPaymentMethod = async () => {+ const setupIntent = async () => {setIntent(undefined)const orgSlug = ui.selectedOrganization?.slug ?? ''const customerId = ui.selectedOrganization?.stripe_customer_id ?? ''diff --git a/studio/components/interfaces/Billing/Billing.types.ts b/studio/components/interfaces/Billing/Billing.types.tsindex 9866fd7773c..be3ebd37e9b 100644--- a/studio/components/interfaces/Billing/Billing.types.ts+++ b/studio/components/interfaces/Billing/Billing.types.ts@@ -1,4 +1,4 @@-// [TODO] I'm guessing this should come from the API?+// I'm guessing this should come from the API?export interface SubscriptionPreview {// Amount due totalamount_due: numberdiff --git a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsxindex 9cd20325825..097c4f91e10 100644--- a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx+++ b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx@@ -60,14 +60,14 @@ const ExitSurvey: FC<Props> = ({ freeTier, onSelectBack }) => {})}- // Submit feedback to Freshdesk (Disabled for local tetsing)- // await post(`${API_URL}/feedback/send`, {- // projectRef,- // subject: 'Subscription cancellation - Exit survey',- // tags: ['dashboard-exitsurvey'],- // category: 'Billing',- // message: generateFeedbackMessage(selectedReasons, values.message),- // })+ // Submit feedback to Freshdesk+ await post(`${API_URL}/feedback/send`, {+ projectRef,+ subject: 'Subscription cancellation - Exit survey',+ tags: ['dashboard-exitsurvey'],+ category: 'Billing',+ message: generateFeedbackMessage(selectedReasons, values.message),+ })// Trigger subscription downgradeconst tier = freeTier.prices[0].iddiff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsxindex a8af43a5e60..31e3075039b 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx@@ -2,13 +2,12 @@ import { FC } from 'react'import { Button, IconLoader } from '@supabase/ui'import { STRIPE_PRODUCT_IDS } from 'lib/constants'-import { BillingPlan } from './Plans.types'import { StripeProduct } from '../..'interface Props {- plan: BillingPlan+ plan: anycurrentPlan?: StripeProduct- onSelectPlan: (plan: BillingPlan) => void+ onSelectPlan: (plan: any) => void}const PlanCTAButton: FC<Props> = ({ plan, currentPlan, onSelectPlan }) => {diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsxindex 2ba7a615f6b..9864997d34c 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx@@ -3,13 +3,12 @@ import { Badge } from '@supabase/ui'import { STRIPE_PRODUCT_IDS } from 'lib/constants'import { StripeProduct } from '../..'-import { BillingPlan } from './Plans.types'import PlanCTAButton from './PlanCTAButton'interface Props {plans: any[]currentPlan?: StripeProduct- onSelectPlan: (plan: BillingPlan) => void+ onSelectPlan: (plan: any) => void}const AnimatedGradientBackground = () => (diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.types.ts b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.types.tsdeleted file mode 100644index 6508f12baac..00000000000--- a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.types.ts+++ /dev/null@@ -1,7 +0,0 @@-export interface BillingPlan {- id?: string- name: string- description: string- pointers: string[]- isPopular: boolean-}diff --git a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx b/studio/components/interfaces/Billing/PlanSelection/index.tsxsimilarity index 93%rename from studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsxrename to studio/components/interfaces/Billing/PlanSelection/index.tsxindex 7c13f3b0cdb..180db2a2708 100644--- a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/index.tsx@@ -4,14 +4,13 @@ import { Transition } from '@headlessui/react'import { StripeProduct } from '..'import Plans from './Plans/Plans'-import { BillingPlan } from './Plans/Plans.types'import { formatTierOptions } from './PlanSelection.utils'interface Props {visible: booleantiers: any[]currentPlan?: StripeProduct- onSelectPlan: (plan: BillingPlan) => void+ onSelectPlan: (plan: any) => void}const PlanSelection: FC<Props> = ({ visible, tiers, currentPlan, onSelectPlan }) => {diff --git a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsxindex d978e3d76c5..d350b853dd0 100644--- a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx+++ b/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.tsx@@ -4,7 +4,6 @@ import { useRouter } from 'next/router'import { Badge, Button, IconArrowLeft, IconHelpCircle, Toggle, Modal } from '@supabase/ui'import { useStore } from 'hooks'-import { getURL } from 'lib/helpers'import { post, patch } from 'lib/common/fetch'import { API_URL } from 'lib/constants'import Divider from 'components/ui/Divider'@@ -82,21 +81,6 @@ const ProUpgrade: FC<Props> = ({setSelectedComputeSize(option)}- const redirectToPortal = async (path: any) => {- try {- const stripeCustomerId = ui.selectedOrganization?.stripe_customer_id- if (!stripeCustomerId) throw new Error("Unable to get organization's Stripe ID")-- let { billingPortal } = await post(`${API_URL}/stripe/billing`, {- stripe_customer_id: stripeCustomerId,- returnTo: `${getURL()}${router.asPath}`,- })- window.location.replace(billingPortal + (path ? path : null))- } catch (error: any) {- ui.setNotification({ category: 'error', message: `Failed to redirect: ${error.message}` })- }- }-const getSubscriptionPreview = async () => {if (!selectedTier) return@@ -239,10 +223,7 @@ const ProUpgrade: FC<Props> = ({selectedPaymentMethod={selectedPaymentMethod}onSelectPaymentMethod={setSelectedPaymentMethod}onSelectAddNewPaymentMethod={() => {- // [TODO] For now, use stripe's web portal to add payment method- // redirectToPortal('/payment-methods')setShowAddPaymentMethodModal(true)- // onSelectAddNewPaymentMethod()}}onConfirmPayment={onConfirmPayment}isSubmitting={isSubmitting}diff --git a/studio/components/interfaces/Billing/index.ts b/studio/components/interfaces/Billing/index.tsindex 9f85d2861a3..27ff4817fd4 100644--- a/studio/components/interfaces/Billing/index.ts+++ b/studio/components/interfaces/Billing/index.ts@@ -1,7 +1,7 @@import PAYGUsage from './PAYGUsage/PAYGUsage'import Subscription from './Subscription/Subscription'-import PlanSelection from './PlanSelection/PlanSelection'+import PlanSelection from './PlanSelection'import ProUpgrade from './ProUpgrade/ProUpgrade'import EnterpriseRequest from './EnterpriseRequest'import ExitSurvey from './ExitSurvey/ExitSurvey'diff --git a/studio/pages/project/[ref]/settings/billing/update/index.tsx b/studio/pages/project/[ref]/settings/billing/update/index.tsxindex 0277e706938..75037d670a2 100644--- a/studio/pages/project/[ref]/settings/billing/update/index.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/index.tsx@@ -11,17 +11,8 @@ import { API_URL, DEFAULT_FREE_PROJECTS_LIMIT, STRIPE_PRODUCT_IDS } from 'lib/coimport { BillingLayout } from 'components/layouts'import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'import { PlanSelection, StripeSubscription } from 'components/interfaces/Billing'-import { BillingPlan } from 'components/interfaces/Billing/PlanSelection/Plans/Plans.types'import Connecting from 'components/ui/Loading/Loading'-/**- * [Joshen] Right now everything is scaffolded without any API calls- * So maybe some prop passing down, variable creation needs relooking- * once I'm working with proper data- */--// [CURRENTLY: Hooking up products from API, and removing all the constants crap]-const BillingUpdate: NextPage = () => {const { ui } = useStore()const router = useRouter()@@ -37,7 +28,7 @@ const BillingUpdate: NextPage = () => {const [products, setProducts] = useState<{ tiers: any[]; addons: any[] }>()const [subscription, setSubscription] = useState<StripeSubscription>()- const [selectedPlan, setSelectedPlan] = useState<BillingPlan>()+ const [selectedPlan, setSelectedPlan] = useState<any>()useEffect(() => {if (projectRef) {@@ -85,7 +76,7 @@ const BillingUpdate: NextPage = () => {}}- const onSelectPlan = (plan: BillingPlan) => {+ const onSelectPlan = (plan: any) => {if (plan.name === 'Enterprise') {return router.push(`/project/${projectRef}/settings/billing/update/enterprise`)} else if (plan.id === STRIPE_PRODUCT_IDS.PRO) {@@ -126,7 +117,6 @@ const BillingUpdate: NextPage = () => {/></div>- {/* [Joshen] Possible refactor, shift this into PlanSelection */}<ConfirmModaldangervisible={showConfirmDowngrade}diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsxindex f7e101242ea..72035f72b3d 100644--- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx@@ -5,7 +5,7 @@ import { useRouter } from 'next/router'import { withAuth, useStore } from 'hooks'import { get, post } from 'lib/common/fetch'-import { API_URL, STRIPE_PRODUCT_IDS } from 'lib/constants'+import { API_URL } from 'lib/constants'import { BillingLayout } from 'components/layouts'import Connecting from 'components/ui/Loading/Loading'@@ -98,7 +98,6 @@ const BillingUpdatePro: NextPage = () => {}}- // tempif (!products || !subscription) return <Connecting />return (