Skip to content

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

Refactor BillingLayout to fit use case for Pro upgrade page and midway implement pro upgrade page

Joshen Limdca1b6201b13
diff --git a/studio/components/interfaces/Billing/ComputeSizeSelection/ComputeSizeSelection.tsx b/studio/components/interfaces/Billing/ComputeSizeSelection/ComputeSizeSelection.tsx
new file mode 100644
index 00000000000..eb6c1f98f5d
--- /dev/null
+++ b/studio/components/interfaces/Billing/ComputeSizeSelection/ComputeSizeSelection.tsx
@@ -0,0 +1,9 @@
+import { FC } from 'react'
+
+interface Props {}
+
+const ComputeSizeSelection: FC<Props> = ({}) => {
+ return <div />
+}
+
+export default ComputeSizeSelection
diff --git a/studio/components/interfaces/Billing/EnterpriseRequest.tsx b/studio/components/interfaces/Billing/EnterpriseRequest.tsx
index 9194aa952de..31c38fb762f 100644
--- a/studio/components/interfaces/Billing/EnterpriseRequest.tsx
+++ b/studio/components/interfaces/Billing/EnterpriseRequest.tsx
@@ -50,7 +50,7 @@ const EnterpriseRequest: FC<Props> = ({ visible, onSelectBack }) => {
</Button>
</div>
<div className="space-y-1">
- <h4 className="text-xl">Customised plans tailored for your business needs</h4>
+ <h4 className="text-lg">Customised plans tailored for your business needs</h4>
<p className="text-scale-1100">
Let us know a few details and we’ll be in contact with you!
</p>
diff --git a/studio/components/interfaces/Billing/ExitSurvey.tsx b/studio/components/interfaces/Billing/ExitSurvey.tsx
index e37a0cfc4bc..f589a395941 100644
--- a/studio/components/interfaces/Billing/ExitSurvey.tsx
+++ b/studio/components/interfaces/Billing/ExitSurvey.tsx
@@ -58,7 +58,7 @@ const ExitSurvey: FC<Props> = ({ visible, onSelectBack }) => {
</Button>
</div>
<div className="space-y-1">
- <h4 className="text-xl">We're sad that you're leaving.</h4>
+ <h4 className="text-lg">We're sad that you're leaving.</h4>
<p className="text-scale-1100">
We always strive to improve Supabase as much as we can. Please let us know the
reasons you are cancelling your subscription so that we can improve in the future.
diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx
new file mode 100644
index 00000000000..87327b3f853
--- /dev/null
+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel.tsx
@@ -0,0 +1,36 @@
+import Divider from 'components/ui/Divider'
+import { FC } from 'react'
+
+interface Props {}
+
+const PaymentSummaryPanel: FC<Props> = ({}) => {
+ return (
+ <div
+ className="bg-scale-300 w-full px-20 py-10 space-y-8"
+ style={{ height: 'calc(100vh - 49.5px)' }}
+ >
+ <p>Payment Summary</p>
+ <div className="space-y-1">
+ <p className="text-sm">Selected subscription</p>
+ </div>
+ <div className="space-y-1">
+ <p className="text-sm">Selected add-ons</p>
+ </div>
+ <div className="h-px w-full bg-scale-600"></div>
+ <div className="flex items-start justify-between space-x-16">
+ <div className="space-y-1">
+ <p>Amount due immediately</p>
+ <p className="text-sm text-scale-1100">
+ Your next invoice of $25 + usage fees will be charged on the 1st February 2022
+ </p>
+ </div>
+ <div className="flex justify-end items-end">
+ <p className="text-scale-1100 relative -top-[1px]">$</p>
+ <p className="text-2xl">0</p>
+ </div>
+ </div>
+ </div>
+ )
+}
+
+export default PaymentSummaryPanel
diff --git a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx b/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx
index f8abed9a9b5..512ce2bd760 100644
--- a/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx
+++ b/studio/components/interfaces/Billing/PlanSelection/PlanSelection.tsx
@@ -26,7 +26,7 @@ const PlanSelection: FC<Props> = ({ visible, billingPlans, currentPlan, onSelect
// leaveTo="transform opacity-0 -translate-x-10"
>
<div className="space-y-8">
- <h4 className="text-xl">Change your project's subscription</h4>
+ <h4 className="text-lg">Change your project's subscription</h4>
{/* FE will make a call to fetch all plans first at the page level */}
<Loading active={!currentPlan}>
<Plans plans={billingPlans} currentPlan={currentPlan} onSelectPlan={onSelectPlan} />
diff --git a/studio/components/interfaces/Billing/ProUpgrade.tsx b/studio/components/interfaces/Billing/ProUpgrade.tsx
new file mode 100644
index 00000000000..b57644ec21b
--- /dev/null
+++ b/studio/components/interfaces/Billing/ProUpgrade.tsx
@@ -0,0 +1,75 @@
+import { FC } from 'react'
+import { Transition } from '@headlessui/react'
+import { Badge, Button, IconArrowLeft, IconHelpCircle, Toggle } from '@supabase/ui'
+
+import { PaymentSummaryPanel } from '.'
+import Divider from 'components/ui/Divider'
+
+interface Props {
+ visible: boolean
+ onSelectBack: () => void
+}
+
+const ProUpgrade: FC<Props> = ({ visible, onSelectBack }) => {
+ return (
+ <Transition
+ show={visible}
+ enter="transition ease-out duration-300"
+ enterFrom="transform opacity-0 translate-x-10"
+ enterTo="transform opacity-100 translate-x-0"
+ className="w-full flex items-start justify-between"
+ >
+ {visible && (
+ <>
+ <div className="space-y-8 w-3/5">
+ <div className="relative ml-64 mr-20">
+ <div className="absolute top-[2px] -left-24">
+ <Button type="text" icon={<IconArrowLeft />} onClick={onSelectBack}>
+ Back
+ </Button>
+ </div>
+ <div className="space-y-8">
+ <h4 className="text-lg">Change your project's subscription</h4>
+ <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="flex items-start justify-between">
+ <div>
+ <div className="flex items-center space-x-2">
+ <p>Enable overages</p>
+ <IconHelpCircle
+ size={16}
+ strokeWidth={1.5}
+ className="cursor-pointer opacity-50 hover:opacity-100 transition"
+ onClick={() => {}}
+ />
+ </div>
+ <p className="text-sm text-scale-1100">
+ Additional resources will be charged on a usage basis
+ </p>
+ </div>
+ <Toggle />
+ </div>
+ <Divider light />
+ <div className="flex items-center space-x-2">
+ <h4 className="text-lg">Extend your project with add-ons</h4>
+ <Badge color="green">Optional</Badge>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div className="w-2/5 -mt-10">
+ <PaymentSummaryPanel />
+ </div>
+ </>
+ )}
+ </Transition>
+ )
+}
+
+export default ProUpgrade
diff --git a/studio/components/interfaces/Billing/Subscription/UpgradeButton.tsx b/studio/components/interfaces/Billing/Subscription/UpgradeButton.tsx
index 6c0a12b12f9..5be0c0793b1 100644
--- a/studio/components/interfaces/Billing/Subscription/UpgradeButton.tsx
+++ b/studio/components/interfaces/Billing/Subscription/UpgradeButton.tsx
@@ -55,7 +55,7 @@ const UpgradeButton: FC<Props> = ({ projectRef, paid, subscriptionStats }) => {
function handleUpgradeButton() {
if (paid) {
- if (freeProjectsOwned >= DEFAULT_FREE_PROJECTS_LIMIT) {
+ if (freeProjectsOwned >= freeProjectsLimit) {
setShowFreeProjectLimitWarning(true)
} else {
setExitSurveyVisible(true)
diff --git a/studio/components/interfaces/Billing/index.ts b/studio/components/interfaces/Billing/index.ts
index d87abd8fad1..c5d4148b731 100644
--- a/studio/components/interfaces/Billing/index.ts
+++ b/studio/components/interfaces/Billing/index.ts
@@ -1,9 +1,19 @@
import PAYGUsage from './PAYGUsage/PAYGUsage'
import Subscription from './Subscription/Subscription'
import PlanSelection from './PlanSelection/PlanSelection'
+import ProUpgrade from './ProUpgrade'
import EnterpriseRequest from './EnterpriseRequest'
import ExitSurvey from './ExitSurvey'
+import PaymentSummaryPanel from './PaymentSummaryPanel'
export * from './Subscription/Subscription.types'
export * from './PAYGUsage/PAYGUsage.constants'
-export { PAYGUsage, Subscription, PlanSelection, EnterpriseRequest, ExitSurvey }
+export {
+ PAYGUsage,
+ Subscription,
+ PlanSelection,
+ ProUpgrade,
+ EnterpriseRequest,
+ ExitSurvey,
+ PaymentSummaryPanel,
+}
diff --git a/studio/components/layouts/BillingLayout.tsx b/studio/components/layouts/BillingLayout.tsx
index eef77b0a6c0..8ed36e1a46d 100644
--- a/studio/components/layouts/BillingLayout.tsx
+++ b/studio/components/layouts/BillingLayout.tsx
@@ -44,7 +44,8 @@ const BillingLayout: FC<Props> = ({ children }) => {
</div>
</div>
<div className="overflow-auto">
- <section className="mx-auto max-w-4xl relative my-10">{children}</section>
+ {/* <section className="mx-auto max-w-4xl relative my-10">{children}</section> */}
+ <section className="relative">{children}</section>
</div>
</div>
</BaseLayout>
diff --git a/studio/pages/project/[ref]/settings/billing/update.tsx b/studio/pages/project/[ref]/settings/billing/update.tsx
index ad1edc42380..4861a03b20a 100644
--- a/studio/pages/project/[ref]/settings/billing/update.tsx
+++ b/studio/pages/project/[ref]/settings/billing/update.tsx
@@ -11,6 +11,7 @@ import { BillingLayout } from 'components/layouts'
import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'
import {
PlanSelection,
+ ProUpgrade,
EnterpriseRequest,
ExitSurvey,
StripeSubscription,
@@ -33,6 +34,10 @@ const BillingUpdate: NextPage = () => {
const [subscription, setSubscription] = useState<StripeSubscription>()
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])
@@ -80,20 +85,24 @@ const BillingUpdate: NextPage = () => {
return (
<BillingLayout>
- <PlanSelection
- visible={!selectedPlan || (selectedPlan && showConfirmDowngrade)}
- billingPlans={BILLING_PLANS}
- currentPlan={subscription}
- onSelectPlan={onSelectPlan}
- />
- <EnterpriseRequest
- visible={selectedPlan?.name === 'Enterprise'}
- onSelectBack={() => setSelectedPlan(undefined)}
- />
- <ExitSurvey
- visible={selectedPlan?.name === 'Free' && !showConfirmDowngrade}
- onSelectBack={() => setSelectedPlan(undefined)}
- />
+ <div className="mx-auto max-w-4xl my-10">
+ <PlanSelection
+ visible={!selectedPlan || (selectedPlan && showConfirmDowngrade)}
+ billingPlans={BILLING_PLANS}
+ currentPlan={subscription}
+ onSelectPlan={onSelectPlan}
+ />
+ <EnterpriseRequest
+ visible={selectedPlan?.name === 'Enterprise'}
+ onSelectBack={() => setSelectedPlan(undefined)}
+ />
+ <ExitSurvey
+ visible={selectedPlan?.name === 'Free' && !showConfirmDowngrade}
+ onSelectBack={() => setSelectedPlan(undefined)}
+ />
+ </div>
+
+ <ProUpgrade visible={showProPlanPage} onSelectBack={() => setSelectedPlan(undefined)} />
<ConfirmModal
danger