import { useParams } from 'common' import { plans as subscriptionsPlans } from 'shared-data/plans' import { AwsMarketplacePurchaseCallout } from './AwsMarketplacePurchaseCallout' import { EnterpriseCard } from './EnterpriseCard' import { PlanCard } from './PlanCard' import { getLiftedSide } from './PlanCards.utils' import { getPlanChangeType } from '@/components/interfaces/Billing/Subscription/Subscription.utils' import type { OrgPlan, PlanId } from '@/data/subscriptions/types' import { useTrack } from '@/lib/telemetry/track' import type { Organization } from '@/types/base' export interface PlanCardsProps { availablePlans: OrgPlan[] isLoadingPlans: boolean currentSubscriptionPlanId: PlanId | undefined currentSubscriptionPlanName: string | undefined canUpdateSubscription: boolean isPartnerBilledOrganization: boolean hasOrioleProjects: boolean selectedOrganization: Organization | undefined showAwsMarketplacePurchase?: boolean onSelectTier: (tier: 'tier_free' | 'tier_pro' | 'tier_team') => void } export function PlanCards({ availablePlans, isLoadingPlans, currentSubscriptionPlanId, currentSubscriptionPlanName, canUpdateSubscription, isPartnerBilledOrganization, hasOrioleProjects, selectedOrganization, showAwsMarketplacePurchase = false, onSelectTier, }: PlanCardsProps) { const { source } = useParams() const track = useTrack() const currentPlanIndex = subscriptionsPlans.findIndex( (plan) => plan.planId === currentSubscriptionPlanId ) return (
{subscriptionsPlans.map((plan, index) => { const planMeta = availablePlans.find((p) => p.id === plan.id.split('tier_')[1]) const price = planMeta?.price ?? 0 const isDowngradeOption = getPlanChangeType(currentSubscriptionPlanId, plan?.planId) === 'downgrade' const isCurrentPlan = index === currentPlanIndex const liftedSide = getLiftedSide({ index, liftedIndex: currentPlanIndex }) const shouldHighlight = source === 'log-drains-empty-state' && plan.id === 'tier_pro' if (plan.id === 'tier_enterprise') { return ( ) } return ( onSelectTier(plan.id as 'tier_free' | 'tier_pro' | 'tier_team')} onTrackCtaClick={() => track('studio_pricing_plan_cta_clicked', { selectedPlan: plan.name, currentPlan: currentSubscriptionPlanName, origin: source, }) } /> ) })} {showAwsMarketplacePurchase && (
)}
) }