Files
supabase/apps/studio/components/interfaces/Billing/Subscription/Subscription.utils.ts
Joshen Lim a0cec24f49 Remove references to fly (#48648)
## Context

As per PR title - should not have any visual nor functional change 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Changes**
- Standardized infrastructure, region, and database configuration around
AWS-based environments.
- Removed Fly.io-specific region and provider options from project
creation, instance sizing, and infrastructure settings.
- Enabled disk validation, spend-cap eligibility, backup restoration,
and extension setup consistently across supported projects.
- Updated billing and region displays to use the applicable AWS
configuration.
- **Bug Fixes**
- Corrected project-specific restrictions that could incorrectly hide
configuration and billing controls.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-03 21:14:50 +07:00

84 lines
2.1 KiB
TypeScript

import type { OrgSubscription, PlanId, ProjectSelectedAddon } from '@/data/subscriptions/types'
import { IS_PLATFORM } from '@/lib/constants'
export const getAddons = (selectedAddons: ProjectSelectedAddon[]) => {
const computeInstance = selectedAddons.find((addon) => addon.type === 'compute_instance')
const pitr = selectedAddons.find((addon) => addon.type === 'pitr')
const customDomain = selectedAddons.find((addon) => addon.type === 'custom_domain')
const ipv4 = selectedAddons.find((addon) => addon.type === 'ipv4')
return { computeInstance, pitr, customDomain, ipv4 }
}
export const subscriptionHasHipaaAddon = (subscription?: OrgSubscription): boolean => {
if (!IS_PLATFORM) return false
return (subscription?.addons ?? []).some(
(addon) => addon.supabase_prod_id === 'addon_security_hipaa'
)
}
export const billingPartnerLabel = (billingPartner?: string) => {
if (!billingPartner) return billingPartner
switch (billingPartner) {
case 'aws':
return 'AWS'
case 'vercel_marketplace':
return 'Vercel'
default:
return billingPartner
}
}
type PlanChangeType = 'upgrade' | 'downgrade' | 'none'
export const getPlanChangeType = (
fromPlan: PlanId | undefined,
toPlan: PlanId | undefined
): PlanChangeType => {
const planChangeTypes: Record<PlanId, Record<PlanId, PlanChangeType>> = {
free: {
free: 'none',
pro: 'upgrade',
team: 'upgrade',
enterprise: 'upgrade',
platform: 'upgrade',
},
pro: {
free: 'downgrade',
pro: 'none',
team: 'upgrade',
enterprise: 'upgrade',
platform: 'upgrade',
},
team: {
free: 'downgrade',
pro: 'downgrade',
team: 'none',
enterprise: 'upgrade',
platform: 'upgrade',
},
enterprise: {
free: 'downgrade',
pro: 'downgrade',
team: 'downgrade',
enterprise: 'none',
platform: 'upgrade',
},
platform: {
free: 'downgrade',
pro: 'downgrade',
team: 'downgrade',
enterprise: 'downgrade',
platform: 'none',
},
}
if (!fromPlan || !toPlan) {
return 'none'
}
return planChangeTypes[fromPlan]?.[toPlan] ?? 'none'
}