Files
supabase/apps/studio/components/interfaces/Organization/BillingSettings/BillingSettings.tsx
Joshen Lim 434c00cb14 Joshenlim/fe 5196 move off scaffold components for remaining (#53911)
## Context

Final clean up of deprecated Scaffold components, just touches
- Account audit logs
- Project home page
- Database -> Column privileges
- Storage -> Analytics bucket details
- Storage -> Vector bucket details
- Settings -> Infrastructure -> Disk management
- Settings -> Infrastructure -> Read replica details
- Integrations -> Wrappers overview (Only for non supported integration
UI)
- Edge functions -> Empty state
- Auth -> Performance

Also replaces usage of `ScaffoldDivider` with just the `Separator`
component
And also adjusts the page container sizes of database pages from large
to default - these only have visual differences on viewport widths
larger than a laptop

Testing just needs a quick sweep of all these surfaces to make sure
nothing looks weird - will do so on my end too once the builds go
through!

For @supabase/security's review - review requirement was triggered as
`Documents.tsx` was updated in the organization settings page. But it
was just to change the Divider component 🙏
2026-11-26 21:28:17 +07:00

121 lines
3.5 KiB
TypeScript

import { cn, Separator } from 'ui'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
PageHeaderMeta,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
import PaymentMethods from '../../Billing/Payment/PaymentMethods/PaymentMethods'
import { InvoicesSection } from '../InvoicesSettings/InvoicesSection'
import BillingBreakdown from './BillingBreakdown/BillingBreakdown'
import { BillingCustomerData } from './BillingCustomerData/BillingCustomerData'
import BillingEmail from './BillingEmail'
import { CostControl } from './CostControl/CostControl'
import CreditBalance from './CreditBalance'
import Subscription from './Subscription/Subscription'
import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { MANAGED_BY } from '@/lib/constants/infrastructure'
export const BillingSettings = () => {
const {
billingAccountData: isBillingAccountDataEnabledOnProfileLevel,
billingPaymentMethods: isBillingPaymentMethodsEnabledOnProfileLevel,
billingCredits: isBillingCreditsEnabledOnProfileLevel,
billingInvoices: isBillingInvoicesEnabledOnProfileLevel,
} = useIsFeatureEnabled([
'billing:account_data',
'billing:payment_methods',
'billing:credits',
'billing:invoices',
])
const { data: org } = useSelectedOrganizationQuery()
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })
const isNotOrgWithPartnerBilling = !subscription?.billing_via_partner
const isStripeOrg = org?.managed_by === MANAGED_BY.STRIPE_PROJECTS
const billingAccountDataEnabled =
isBillingAccountDataEnabledOnProfileLevel && isNotOrgWithPartnerBilling
const billingPaymentMethodsEnabled =
isBillingPaymentMethodsEnabledOnProfileLevel && (isNotOrgWithPartnerBilling || isStripeOrg)
return (
<>
<PageHeader>
<PageHeaderMeta>
<PageHeaderSummary>
<PageHeaderTitle>Billing</PageHeaderTitle>
</PageHeaderSummary>
</PageHeaderMeta>
</PageHeader>
<PageContainer id="subscription" className={cn('[&>div]:pt-0!')}>
<Subscription />
</PageContainer>
<Separator />
<PageContainer id="cost-control">
<CostControl />
</PageContainer>
<Separator />
{org && org.plan.id !== 'free' && (
<PageContainer id="breakdown">
<BillingBreakdown />
</PageContainer>
)}
{isBillingInvoicesEnabledOnProfileLevel && (
<>
<Separator />
<PageContainer id="invoices">
<InvoicesSection />
</PageContainer>
</>
)}
{billingPaymentMethodsEnabled && (
<>
<Separator />
<PageContainer id="payment-methods">
<PaymentMethods />
</PageContainer>
</>
)}
{isBillingCreditsEnabledOnProfileLevel && (
<>
<Separator />
<PageContainer id="credits-balance">
<CreditBalance />
</PageContainer>
</>
)}
{billingAccountDataEnabled && (
<>
<Separator />
<PageContainer id="email">
<BillingEmail />
</PageContainer>
<Separator />
<PageContainer id="address">
<BillingCustomerData />
</PageContainer>
</>
)}
</>
)
}