The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update payment summary to support transition between pro and payg
Joshen Limf96922c778f0
diff --git a/studio/components/interfaces/Billing/AddOns/AddOns.constant.ts b/studio/components/interfaces/Billing/AddOns/AddOns.constant.tsindex b847bfe806f..ec516b17645 100644--- a/studio/components/interfaces/Billing/AddOns/AddOns.constant.ts+++ b/studio/components/interfaces/Billing/AddOns/AddOns.constant.ts@@ -1,4 +1,4 @@-// Temp hard-code+// Temp hard-code, should fetch all available add ons from APIexport const COMPUTE_SIZES = [{id: 1,@@ -8,28 +8,28 @@ export const COMPUTE_SIZES = [price: 0,},{- id: 2,+ id: 'prod_KrzaPTzPj1KAYB',name: 'Medium',description: 'Great for projects that are starting to gain traction',specs: '2 CPUs • 4GB memory • 2,085Mbps Disk IO',price: 50,},{- id: 3,+ id: 'prod_KrzZKxuF2YNsjR',name: 'Large',description: 'For a large project that receives a decent amount of traffic',specs: '2 CPUs • 8GB memory • 4,750Mbps Disk IO',price: 100,},{- id: 4,+ id: 'prod_KF94pLcOx5PSlp',name: 'X-Large',description: 'For a large project that receives a sizeable amount of traffic',specs: '4 CPUs • 16GB memory • 4,750Mbps Disk IO',price: 200,},{- id: 5,+ id: 'prod_KrzapWYxUYmve5',name: 'XX-Large',description: 'For a huge project that receives heavy amount of traffic',specs: '8 CPUs • 32GB memory • 4,750Mbps Disk IO',diff --git a/studio/components/interfaces/Billing/EnterpriseRequest.tsx b/studio/components/interfaces/Billing/EnterpriseRequest.tsxindex 31c38fb762f..252a9d0095a 100644--- a/studio/components/interfaces/Billing/EnterpriseRequest.tsx+++ b/studio/components/interfaces/Billing/EnterpriseRequest.tsx@@ -1,6 +1,7 @@import { FC } from 'react'import { Transition } from '@headlessui/react'import { Button, Form, Input, IconArrowLeft } from '@supabase/ui'+import { useStore } from 'hooks'import { timeout } from 'lib/helpers'interface Props {@@ -9,9 +10,12 @@ interface Props {}const EnterpriseRequest: FC<Props> = ({ visible, onSelectBack }) => {+ const { ui } = useStore()+ const { profile } = ui+const initialValues = {- name: '',- email: '',+ name: `${profile?.first_name} ${profile?.last_name}`,+ email: profile?.primary_email,company: '',message: '',}@@ -33,14 +37,7 @@ const EnterpriseRequest: FC<Props> = ({ visible, onSelectBack }) => {enter="transition ease-out duration-300"enterFrom="transform opacity-0 translate-x-10"enterTo="transform opacity-100 translate-x-0"- // leave="transition ease-in duration-75"- // leaveFrom="transform opacity-100"- // leaveTo="transform opacity-0 -translate-x-10">- {/*- Fix for weird UI bug whereby transitions dont clear immediately- causing the UI to stack over each other for a split second- */}{visible && (<div className="space-y-8 w-4/5"><div className="relative">@@ -63,7 +60,7 @@ const EnterpriseRequest: FC<Props> = ({ visible, onSelectBack }) => {>{({ isSubmitting }: { isSubmitting: boolean }) => (<div className="space-y-12 py-16">- <div className="space-y-4">+ <div className="space-y-4 w-3/5"><Input layout="horizontal" label="Name" id="name" name="name" /><Input layout="horizontal" label="Email" id="email" name="email" /><Input layout="horizontal" label="Company" id="company" name="company" />diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel.tsxindex 9afe0b5ee4b..72925914c66 100644--- a/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx@@ -1,12 +1,13 @@import { FC } from 'react'-import { Listbox, IconLoader } from '@supabase/ui'+import { Listbox, IconLoader, Button } from '@supabase/ui'-import { StripeSubscription } from '.'+import { StripeProduct } from '.'import { BillingPlan } from './PlanSelection/Plans/Plans.types'+import { STRIPE_PRODUCT_IDS } from 'lib/constants'interface Props {- currentPlan: StripeSubscription- currentComputeSize?: any+ currentPlan: StripeProduct+ currentComputeSize: anyselectedPlan?: BillingPlanselectedComputeSize: anyisOverageEnabled: boolean@@ -14,6 +15,7 @@ interface Props {selectedPaymentMethod: anyisLoadingPaymentMethods: booleanonSelectPaymentMethod: (method: any) => void+ onConfirmPayment: () => void}// Use case of this panel is actually only for upgrading from Free to Pro@@ -21,7 +23,7 @@ interface Props {// within this boundary// [Joshen] Eventually if we do support more addons, it'll be better to generalize-// the selectedComputeSize to an addOns array. But for now, we keep it simple+// the selectedComputeSize to an addOns array. But for now, we keep it simple, don't over-engineer too earlyconst PaymentSummaryPanel: FC<Props> = ({currentPlan,@@ -33,10 +35,21 @@ const PaymentSummaryPanel: FC<Props> = ({selectedPaymentMethod,isLoadingPaymentMethods,onSelectPaymentMethod,+ onConfirmPayment,}) => {- const isChangingPlan = selectedPlan !== undefined+ const isChangingPlan =+ (currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && currentPlan.prod_id !== selectedPlan?.id) ||+ (currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && isOverageEnabled) ||+ (currentPlan.prod_id === STRIPE_PRODUCT_IDS.PAYG && !isOverageEnabled)+ const isChangingComputeSize = currentComputeSize.id !== selectedComputeSize.id+ const hasChangesToPlan = isChangingPlan || isChangingComputeSizeconst totalMonthlyCost = (selectedPlan?.price ?? 0) + selectedComputeSize.price+ const getCurrentPlanName = () => {+ if (currentPlan.prod_id === STRIPE_PRODUCT_IDS.PAYG) return 'Pro tier (Overages enabled)'+ else return currentPlan.name+ }+return (<divclassName="bg-scale-300 w-full px-20 py-10 space-y-8"@@ -49,16 +62,16 @@ const PaymentSummaryPanel: FC<Props> = ({<p className="text-sm">Selected subscription</p><div className="flex items-center justify-between"><p className={`${isChangingPlan ? 'text-scale-1100 line-through' : ''} text-sm`}>- {currentPlan.tier.name}+ {getCurrentPlanName()}</p><p className={`${isChangingPlan ? 'text-scale-1100 line-through' : ''} text-sm`}>- ${currentPlan.tier.unit_amount}+ ${currentPlan.unit_amount / 100}</p></div>{isChangingPlan && (<div className="flex items-center justify-between"><p className="text-sm">- {selectedPlan?.name} {isOverageEnabled ? '(Overages enabled)' : ''}+ {selectedPlan?.name} tier {isOverageEnabled ? '(Overages enabled)' : ''}</p><p className="text-sm">${selectedPlan?.price}</p></div>@@ -71,7 +84,17 @@ const PaymentSummaryPanel: FC<Props> = ({{currentComputeSize === undefined && selectedComputeSize === undefined && (<p className="text-scale-1100 text-sm">No add-ons selected</p>)}- {selectedComputeSize !== undefined && (+ {currentComputeSize !== undefined && (+ <div className="flex items-center justify-between">+ <p className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>+ Optimized database instance ({currentComputeSize.name})+ </p>+ <p className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>+ ${currentComputeSize.price}+ </p>+ </div>+ )}+ {isChangingComputeSize && (<div className="flex items-center justify-between"><p className="text-sm">Optimized database instance ({selectedComputeSize.name})</p><p className="text-sm">${selectedComputeSize.price}</p>@@ -82,58 +105,71 @@ const PaymentSummaryPanel: FC<Props> = ({<div className="h-px w-full bg-scale-600"></div>{/* Payment total */}- <div className="flex items-start justify-between space-x-16">+ <div className="flex items-start justify-between space-x-32"><div className="space-y-1">- <p>Amount due immediately</p>- <p className="text-sm text-scale-1100">- Your next invoice of ${totalMonthlyCost} {isOverageEnabled && '+ usage fees '}will be- charged on the 1st February 2022- </p>+ <p>Amount due today</p>+ {hasChangesToPlan && (+ <p className="text-sm text-scale-1100">+ You'll pay a monthly total of{' '}+ <span className="text-scale-1200">+ ${totalMonthlyCost} {isOverageEnabled && '+ usage fees '}+ </span>+ starting on 1st February 2022+ </p>+ )}</div>- <div className="flex justify-end items-end">+ <div className="flex justify-end items-end relative -top-[5px]"><p className="text-scale-1100 relative -top-[1px]">$</p><p className="text-2xl">0</p></div></div>{/* Payment method selection */}- {isLoadingPaymentMethods ? (- <div className="flex items-center space-x-4">- <IconLoader className="animate-spin" size={14} />- <p className="text-sm">Retrieving payment methods</p>- </div>- ) : paymentMethods.length === 0 ? (- <div className="text-scale-1100">No methods</div>- ) : (- <Listbox- label="Select payment method"- value={selectedPaymentMethod?.id}- onChange={onSelectPaymentMethod}- >- {paymentMethods.map((method: any) => {- const label = `•••• •••• •••• ${method.card.last4}`- return (- <Listbox.Option- key={method.id}- label={label}- value={method.id}- addOnBefore={() => {- return (- <img- src={`/img/payment-methods/${method.card.brand- .replace(' ', '-')- .toLowerCase()}.png`}- width="32"- />- )- }}- >- <div>{label}</div>- </Listbox.Option>- )- })}- </Listbox>- )}+ <div className="space-y-2">+ <p>Select payment method</p>+ {isLoadingPaymentMethods ? (+ <div className="flex items-center rounded-md space-x-4 px-4 py-2 bg-scale-400 border border-scale-700">+ <IconLoader className="animate-spin" size={14} />+ <p className="text-sm text-scale-1100">Retrieving payment methods</p>+ </div>+ ) : paymentMethods.length === 0 ? (+ // [TODO] We need some UI to allow users to add payment methods here+ <div className="flex items-center rounded-md space-x-4 px-4 py-2 bg-scale-400 border border-scale-700">+ <div className="text-scale-1100">No methods</div>+ </div>+ ) : (+ <Listbox value={selectedPaymentMethod?.id} onChange={onSelectPaymentMethod}>+ {paymentMethods.map((method: any) => {+ const label = `•••• •••• •••• ${method.card.last4}`+ return (+ <Listbox.Option+ key={method.id}+ label={label}+ value={method.id}+ addOnBefore={() => {+ return (+ <img+ src={`/img/payment-methods/${method.card.brand+ .replace(' ', '-')+ .toLowerCase()}.png`}+ width="32"+ />+ )+ }}+ >+ <div>{label}</div>+ </Listbox.Option>+ )+ })}+ </Listbox>+ )}+ </div>++ <div className="flex items-center justify-end">+ <Button type="primary" disabled={!hasChangesToPlan} onClick={onConfirmPayment}>+ Confirm payment+ </Button>+ </div></div>)}diff --git a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx b/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsxindex 932a5bfc329..84b4d3fc053 100644--- a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx@@ -4,12 +4,12 @@ import { Transition } from '@headlessui/react'import Plans from './Plans/Plans'import { BillingPlan } from './Plans/Plans.types'-import { StripeSubscription } from '..'+import { StripeProduct } from '..'interface Props {visible: booleanbillingPlans: BillingPlan[]- currentPlan?: StripeSubscription+ currentPlan?: StripeProductonSelectPlan: (plan: BillingPlan) => void}@@ -20,9 +20,6 @@ const PlanSelection: FC<Props> = ({ visible, billingPlans, currentPlan, onSelectenter="transition ease-out duration-300"enterFrom="transform opacity-0 -translate-x-10"enterTo="transform opacity-100 translate-x-0"- // leave="transition ease-in duration-75"- // leaveFrom="transform opacity-100"- // leaveTo="transform opacity-0 -translate-x-10"><div className="space-y-8"><h4 className="text-lg">Change your project's subscription</h4>diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsxindex 81a0867c912..a8af43a5e60 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx@@ -3,11 +3,11 @@ import { Button, IconLoader } from '@supabase/ui'import { STRIPE_PRODUCT_IDS } from 'lib/constants'import { BillingPlan } from './Plans.types'-import { StripeSubscription } from '../../index'+import { StripeProduct } from '../..'interface Props {plan: BillingPlan- currentPlan?: StripeSubscription+ currentPlan?: StripeProductonSelectPlan: (plan: BillingPlan) => void}@@ -19,21 +19,24 @@ const PlanCTAButton: FC<Props> = ({ plan, currentPlan, onSelectPlan }) => {return 'primary'}- const getButtonText = (plan: any, currentPlan: any) => {+ const getButtonText = (plan: any, currentPlan: StripeProduct) => {if (plan.name === 'Enterprise') {return 'Contact sales'}if (plan.id === STRIPE_PRODUCT_IDS.FREE) {- if (currentPlan.tier.prod_id === STRIPE_PRODUCT_IDS.FREE) {+ if (currentPlan.prod_id === STRIPE_PRODUCT_IDS.FREE) {return 'Current plan'} else {return 'Downgrade to Free'}}if (plan.id === STRIPE_PRODUCT_IDS.PRO) {- if (currentPlan.tier.prod_id === STRIPE_PRODUCT_IDS.FREE) {+ if (currentPlan.prod_id === STRIPE_PRODUCT_IDS.FREE) {return 'Upgrade to Pro'- } else if (currentPlan.tier.prod_id === STRIPE_PRODUCT_IDS.PRO) {+ } else if (+ currentPlan.prod_id === STRIPE_PRODUCT_IDS.PRO ||+ currentPlan.prod_id === STRIPE_PRODUCT_IDS.PAYG+ ) {return 'Edit plan configuration'} else {return 'Contact sales'@@ -53,7 +56,7 @@ const PlanCTAButton: FC<Props> = ({ plan, currentPlan, onSelectPlan }) => {const type = getButtonType(plan)const ctaText = getButtonText(plan, currentPlan)const disabled =- plan.id === STRIPE_PRODUCT_IDS.FREE && currentPlan.tier.prod_id === STRIPE_PRODUCT_IDS.FREE+ plan.id === STRIPE_PRODUCT_IDS.FREE && currentPlan.prod_id === STRIPE_PRODUCT_IDS.FREEreturn (<div className="flex items-center justify-center">diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.constants.ts b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.constants.tsindex 8bb522a9b3b..2c7a1e162af 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.constants.ts+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.constants.ts@@ -1,6 +1,10 @@import { STRIPE_PRODUCT_IDS } from 'lib/constants'import { BillingPlan } from './Plans.types'+// [Joshen] The idea is that API fetch plans will probably receive StripeProduct[]+// FE will keep the other meta information like description, pointers, but everything else+// should be from the API (e.g price) and name+export const BILLING_PLANS: BillingPlan[] = [{id: STRIPE_PRODUCT_IDS.FREE,@@ -9,8 +13,8 @@ export const BILLING_PLANS: BillingPlan[] = [description: 'Zero commitment, perfect for hobby projects and experiments',isPopular: false,pointers: [- 'Postgres database, API server, authentication, storage',- 'Unlimited team members',+ '500MB database & 1GB file storage',+ '2000 monthly active auth users','Community support',],},@@ -21,11 +25,11 @@ export const BILLING_PLANS: BillingPlan[] = [description: 'Designated support team, account manager and technical specialist',isPopular: true,pointers: [- 'Optimized database instances',- 'Usage-based billing, no limits',- 'Automated back-ups',- 'Designated support',- 'Unlimited audit trails',+ '8GB database & 100GB file storage',+ '10,000 monthly active auth users',+ 'Daily backups',+ 'Compute booster packs',+ '7-day log retention',],},{@@ -35,11 +39,11 @@ export const BILLING_PLANS: BillingPlan[] = [description: 'Custom tailored services to suit your specific business needs',isPopular: false,pointers: [- 'Bespoked architecture',- 'SSO / SAML',- 'SOC2 security',- 'Automated scaling',- 'Dedicated support team & SLAs',+ 'Point in time recovery',+ 'Designated Support manager & SLAs',+ 'SSO / SAML + SOC2',+ 'Custom contracts & invoicing',+ '24×7×365 premium enterprise support',],},]diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsxindex 6f2a65ee259..ebf2c8d3942 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/Plans.tsx@@ -2,13 +2,13 @@ import { FC } from 'react'import { Badge } from '@supabase/ui'import { STRIPE_PRODUCT_IDS } from 'lib/constants'-import { StripeSubscription } from '../../index'+import { StripeProduct } from '../..'import { BillingPlan } from './Plans.types'import PlanCTAButton from './PlanCTAButton'interface Props {plans: BillingPlan[]- currentPlan?: StripeSubscription+ currentPlan?: StripeProductonSelectPlan: (plan: BillingPlan) => void}@@ -48,8 +48,13 @@ const Plans: FC<Props> = ({ plans, currentPlan, onSelectPlan }) => {{/* [Joshen] Trying some animations here to make Pro pop, on the fence tbh */}{plan.id === STRIPE_PRODUCT_IDS.PRO && <AnimatedGradientBackground />}- {/* Label to show current subscription */}- {plan.id && plan.id === currentPlan?.tier.prod_id && <CurrentSubscriptionBanner />}+ {/* Label to show current subscription (Pro and PAYG are treated as the same plan on the UI) */}+ {plan.id === currentPlan?.prod_id ||+ (plan.id === STRIPE_PRODUCT_IDS.PRO &&+ (currentPlan?.prod_id === STRIPE_PRODUCT_IDS.PRO ||+ currentPlan?.prod_id === STRIPE_PRODUCT_IDS.PAYG) && (+ <CurrentSubscriptionBanner />+ ))}<div className="mb-8"><div className="flex items-center space-x-4">diff --git a/studio/components/interfaces/Billing/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsxindex ab7f04652a4..dfa231230b0 100644--- a/studio/components/interfaces/Billing/ProUpgrade.tsx+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx@@ -6,27 +6,39 @@ import Divider from 'components/ui/Divider'import { PaymentSummaryPanel, ComputeSizeSelection, StripeSubscription } from '.'import { BillingPlan } from './PlanSelection/Plans/Plans.types'import { COMPUTE_SIZES } from './AddOns/AddOns.constant'+import { STRIPE_PRODUCT_IDS } from 'lib/constants'interface Props {visible: boolean- currentPlan: StripeSubscription+ currentSubscription: StripeSubscriptionselectedPlan?: BillingPlanpaymentMethods?: any[]- onSelectBack: () => void-isLoadingPaymentMethods: boolean+ onSelectBack: () => void+ onConfirmPayment: () => void}const ProUpgrade: FC<Props> = ({visible,- currentPlan,+ currentSubscription,selectedPlan,paymentMethods,- onSelectBack,isLoadingPaymentMethods,+ onSelectBack,+ onConfirmPayment,}) => {- const [isOverageEnabled, setIsOverageEnabled] = useState(false)- const [selectedComputeSize, setSelectedComputeSize] = useState<any>(COMPUTE_SIZES[0])+ const currentComputeSize =+ COMPUTE_SIZES.find((options) => options.id === currentSubscription?.addons[0]?.prod_id) ||+ COMPUTE_SIZES[0]++ const isManagingProSubscription =+ currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PRO ||+ currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG++ const [isOverageEnabled, setIsOverageEnabled] = useState(+ currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG+ )+ const [selectedComputeSize, setSelectedComputeSize] = useState<any>(currentComputeSize)const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<any>()const onSelectComputeSizeOption = (option: any) => {@@ -63,14 +75,25 @@ const ProUpgrade: FC<Props> = ({className="space-y-8 overflow-scroll pb-8 pr-20"style={{ height: 'calc(100vh - 6.3rem - 49.5px)' }}>- <div className="space-y-1">- <h3 className="text-xl">- Welcome to <span className="text-green-1100">Pro</span>- <p className="text-sm text-scale-1100">- Your new subscription will begin immediately after payment- </p>- </h3>- </div>+ {!isManagingProSubscription ? (+ <div className="space-y-1">+ <h3 className="text-xl">+ Welcome to <span className="text-green-1100">Pro</span>+ <p className="text-sm text-scale-1100">+ Your new subscription will begin immediately after payment+ </p>+ </h3>+ </div>+ ) : (+ <div className="space-y-1">+ <h3 className="text-xl">+ Managing your <span className="text-green-1100">Pro</span> plan+ <p className="text-sm text-scale-1100">+ Your billing cycle will reset after payment+ </p>+ </h3>+ </div>+ )}<div className="flex items-start justify-between"><div><div className="flex items-center space-x-2">@@ -106,14 +129,16 @@ const ProUpgrade: FC<Props> = ({</div><div className="w-2/5 -mt-10"><PaymentSummaryPanel- currentPlan={currentPlan}+ currentPlan={currentSubscription.tier}selectedPlan={selectedPlan}isOverageEnabled={isOverageEnabled}+ currentComputeSize={currentComputeSize}selectedComputeSize={selectedComputeSize}paymentMethods={paymentMethods}isLoadingPaymentMethods={isLoadingPaymentMethods}selectedPaymentMethod={selectedPaymentMethod}onSelectPaymentMethod={setSelectedPaymentMethod}+ onConfirmPayment={onConfirmPayment}/></div></>diff --git a/studio/components/interfaces/Billing/Subscription/Subscription.types.ts b/studio/components/interfaces/Billing/Subscription/Subscription.types.tsindex 02269b7eb63..84d96bc2e7e 100644--- a/studio/components/interfaces/Billing/Subscription/Subscription.types.ts+++ b/studio/components/interfaces/Billing/Subscription/Subscription.types.ts@@ -1,18 +1,14 @@export interface StripeSubscription {- tier: {- name: string- prod_id: string- unit_amount: number- }+ tier: StripeProductbilling: {current_period_end: numbercurrent_period_start: numberbilling_cycle_anchor: number}- addons: StripeAddon[]+ addons: StripeProduct[]}-export interface StripeAddon {+export interface StripeProduct {name: stringprod_id: stringunit_amount: numberdiff --git a/studio/pages/project/[ref]/settings/billing/update.tsx b/studio/pages/project/[ref]/settings/billing/update.tsxindex b673196ed9c..453bbe4c38a 100644--- a/studio/pages/project/[ref]/settings/billing/update.tsx+++ b/studio/pages/project/[ref]/settings/billing/update.tsx@@ -19,6 +19,12 @@ import {import { BillingPlan } from 'components/interfaces/Billing/PlanSelection/Plans/Plans.types'import { BILLING_PLANS } from 'components/interfaces/Billing/PlanSelection/Plans/Plans.constants'+/**+ * [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+ */+const BillingUpdate: NextPage = () => {const { ui } = useStore()const projectRef = ui.selectedProject?.ref@@ -28,7 +34,6 @@ const BillingUpdate: NextPage = () => {const freeProjectsLimit = ui?.profile?.free_project_limit ?? DEFAULT_FREE_PROJECTS_LIMITconst freeProjectsOwned = subscriptionStats.total_free_projects ?? 0- const [isLoadingSubscription, setIsLoadingSubscription] = useState(false)const [isLoadingPaymentMethods, setIsLoadingPaymentMethods] = useState(false)const [showConfirmDowngrade, setShowConfirmDowngrade] = useState(false)const [showDowngradeError, setShowDowngradeError] = useState(false)@@ -37,10 +42,6 @@ const BillingUpdate: NextPage = () => {const [paymentMethods, setPaymentMethods] = useState<any>()const [selectedPlan, setSelectedPlan] = useState<BillingPlan>()- const showProPlanPage =- subscription?.tier.prod_id !== STRIPE_PRODUCT_IDS.PRO &&- selectedPlan?.id === STRIPE_PRODUCT_IDS.PRO-useEffect(() => {if (projectRef) getSubscription()}, [projectRef])@@ -69,8 +70,6 @@ const BillingUpdate: NextPage = () => {const getSubscription = async () => {try {- setIsLoadingSubscription(true)-if (!ui.selectedProject?.subscription_id) {throw new Error('Unable to get subscription ID of project')}@@ -88,8 +87,6 @@ const BillingUpdate: NextPage = () => {category: 'error',message: `Failed to get subscription: ${error.message}`,})- } finally {- setIsLoadingSubscription(false)}}@@ -108,13 +105,17 @@ const BillingUpdate: NextPage = () => {setShowConfirmDowngrade(false)}+ const onConfirmPayment = () => {+ console.log('Confirm payment')+ }+return (<BillingLayout>- <div className="mx-auto max-w-4xl my-10">+ <div className="mx-auto max-w-5xl my-10"><PlanSelectionvisible={!selectedPlan || (selectedPlan && showConfirmDowngrade)}billingPlans={BILLING_PLANS}- currentPlan={subscription}+ currentPlan={subscription?.tier}onSelectPlan={onSelectPlan}/><EnterpriseRequest@@ -129,12 +130,16 @@ const BillingUpdate: NextPage = () => {{subscription !== undefined && (<ProUpgrade- visible={showProPlanPage}- currentPlan={subscription}+ visible={+ selectedPlan?.id === STRIPE_PRODUCT_IDS.PRO ||+ selectedPlan?.id === STRIPE_PRODUCT_IDS.PAYG+ }+ currentSubscription={subscription}selectedPlan={selectedPlan}isLoadingPaymentMethods={isLoadingPaymentMethods}paymentMethods={paymentMethods?.data ?? []}onSelectBack={() => setSelectedPlan(undefined)}+ onConfirmPayment={onConfirmPayment}/>)}