NoProjectsOnPaidOrgInfo.tsx34 lines · main
| 1 | import Link from 'next/link' |
| 2 | import { Admonition } from 'ui-patterns' |
| 3 | |
| 4 | import { useOrgProjectsInfiniteQuery } from '@/data/projects/org-projects-infinite-query' |
| 5 | import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' |
| 6 | |
| 7 | const EXCLUDED_PLANS = ['free', 'platform', 'enterprise'] |
| 8 | |
| 9 | export const NoProjectsOnPaidOrgInfo = () => { |
| 10 | const { data: organization } = useSelectedOrganizationQuery() |
| 11 | const isEligible = organization != null && !EXCLUDED_PLANS.includes(organization.plan.id ?? '') |
| 12 | |
| 13 | const { data } = useOrgProjectsInfiniteQuery( |
| 14 | { slug: organization?.slug }, |
| 15 | { enabled: isEligible } |
| 16 | ) |
| 17 | const projectCount = data?.pages[0].pagination.count ?? 0 |
| 18 | |
| 19 | if (!isEligible || projectCount > 0) return null |
| 20 | |
| 21 | return ( |
| 22 | <Admonition |
| 23 | type="default" |
| 24 | title={`Your organization is on the ${organization.plan.name} plan with no projects running`} |
| 25 | description={ |
| 26 | <div className="max-w-full! prose text-sm"> |
| 27 | The monthly fees for the paid plan still apply. To cancel your subscription, head over to |
| 28 | your{' '} |
| 29 | <Link href={`/org/${organization?.slug}/billing`}>organization billing settings</Link> |
| 30 | </div> |
| 31 | } |
| 32 | /> |
| 33 | ) |
| 34 | } |