Skip to content

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

refactor: extract `UpgradeToPro` component

Beng Eubd56d496f798
diff --git a/studio/components/interfaces/Database/Backups/BackupsList.tsx b/studio/components/interfaces/Database/Backups/BackupsList.tsx
index 8ba7c4151bc..a66e989f6bf 100644
--- a/studio/components/interfaces/Database/Backups/BackupsList.tsx
+++ b/studio/components/interfaces/Database/Backups/BackupsList.tsx
@@ -1,12 +1,12 @@
-import Link from 'next/link'
import React, { FC, useState, useEffect } from 'react'
import { observer } from 'mobx-react-lite'
-import { Button, Typography, IconClock, IconInfo } from '@supabase/ui'
+import { Typography, IconInfo } from '@supabase/ui'
import { useStore } from 'hooks'
import { STRIPE_PRODUCT_IDS } from 'lib/constants'
import BackupItem from './BackupItem'
import Loading from 'components/ui/Loading'
+import UpgradeToPro from 'components/ui/UpgradeToPro'
import Panel from 'components/to-be-cleaned/Panel'
interface Props {}
@@ -44,32 +44,11 @@ const BackupsList: FC<Props> = ({}) => {
if (tierId === STRIPE_PRODUCT_IDS.FREE) {
return (
- <div
- className={[
- 'block w-full py-4 px-6 border rounded border-opacity-20',
- 'bg-gray-100 border-gray-600',
- 'dark:bg-gray-400 dark:border-gray-300',
- ].join(' ')}
- >
- <div className="flex space-x-3">
- <div className="mt-1">
- <IconClock size="large" />
- </div>
- <div className="flex justify-between w-full items-center">
- <div>
- <p>Free Plan does not include project backups.</p>
- <div>
- <p className="text-sm text-scale-1100">
- Please upgrade to Pro plan for up to 7 days of backups.
- </p>
- </div>
- </div>
- <Link href={`/project/${projectRef}/settings/billing`}>
- <Button type="primary">Upgrade to Pro</Button>
- </Link>
- </div>
- </div>
- </div>
+ <UpgradeToPro
+ primaryText="Free Plan does not include project backups."
+ projectRef={projectRef}
+ secondaryText="Please upgrade to Pro plan for up to 7 days of backups."
+ />
)
}
diff --git a/studio/components/ui/UpgradeToPro.tsx b/studio/components/ui/UpgradeToPro.tsx
new file mode 100644
index 00000000000..46bc5c0224b
--- /dev/null
+++ b/studio/components/ui/UpgradeToPro.tsx
@@ -0,0 +1,38 @@
+import { Button, IconClock, Typography } from '@supabase/ui'
+import Link from 'next/link'
+import { FC } from 'react'
+
+interface Props {
+ primaryText: string
+ projectRef: string
+ secondaryText: string
+}
+
+const UpgradeToPro: FC<Props> = ({ primaryText, projectRef, secondaryText }) => (
+ <div
+ className={[
+ 'block w-full py-4 px-6 border rounded border-opacity-20',
+ 'bg-gray-100 border-gray-600',
+ 'dark:bg-gray-400 dark:border-gray-300',
+ ].join(' ')}
+ >
+ <div className="flex space-x-3">
+ <div className="mt-1">
+ <IconClock size="large" />
+ </div>
+ <div className="flex justify-between w-full items-center">
+ <div>
+ <p>{primaryText}</p>
+ <div>
+ <p className="text-sm text-scale-1100">{secondaryText}</p>
+ </div>
+ </div>
+ <Link href={`/project/${projectRef}/settings/billing`}>
+ <Button type="primary">Upgrade to Pro</Button>
+ </Link>
+ </div>
+ </div>
+ </div>
+)
+
+export default UpgradeToPro