import React from 'react'; import { Spinner } from '../ui/Spinner'; import { LAUNCH_DISCOUNT_PERCENT } from '../launch-discount/plans'; import { PlanType } from '../../utils/plan'; /** Credits-tier presentation copy for a single plan. */ export interface ICreditTier { eyebrow: string; pricePrefix?: string; priceLabel: string; credits: string; description: string; audience: string; adds?: string; } interface PlanCardProps { planKey: PlanType; planName: string; monthly: number; priceId: string; isPopular: boolean; isFreePlan: boolean; isHyperScaling: boolean; isEnterprise: boolean; currentByTrial: boolean; currentPaid: boolean; isCurrentFree: boolean; showCurrentTag: boolean; ctaLabel: string; ctaDisabled: boolean; isLoadingThisPlan: boolean; isFreeTrialActive: boolean; launchTrial?: boolean; billingLabel: string; stripeSubscriptionStatus: string; tier?: ICreditTier; contactUrl?: string; onInitializePayment: (priceId: string, planKey: PlanType) => void; primaryBtn: string; secondaryBtn: string; } const formatUSD = (amount: number) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: amount % 1 === 0 ? 0 : 2, }).format(amount); export const PlanCard: React.FC = ({ planKey, planName, monthly, priceId, isPopular, isFreePlan, isHyperScaling, isEnterprise, currentByTrial, currentPaid, isCurrentFree, showCurrentTag, ctaLabel, ctaDisabled, isLoadingThisPlan, isFreeTrialActive, launchTrial = false, billingLabel, stripeSubscriptionStatus, tier, contactUrl = 'https://recomaze.ai/contact/', onInitializePayment, primaryBtn, secondaryBtn, }) => { const cardTone = showCurrentTag ? 'ring-2 ring-emerald-500' : 'ring-1 ring-gray-200'; const accentTone = isHyperScaling && !showCurrentTag ? 'bg-gradient-to-b from-indigo-50 to-white ring-indigo-200' : isPopular && !currentPaid && !isCurrentFree && !currentByTrial ? 'bg-white ring-gray-900/20' : 'bg-white ring-gray-200'; const priceLabel = tier?.priceLabel ?? (isFreePlan ? 'Free' : formatUSD(monthly)); return (
{currentByTrial && (
FREE TRIAL • Hyper Scaling
)} {!currentByTrial && isPopular && !currentPaid && !isCurrentFree && (
MOST POPULAR
)} {!currentByTrial && (currentPaid || isCurrentFree) && (
{`CURRENT • ${ isCurrentFree ? 'Free' : billingLabel || 'Monthly' }`}
)}

{tier?.eyebrow ?? planName}

{isEnterprise && ( Enterprise )}
{launchTrial && showCurrentTag ? (
{formatUSD(monthly * (1 - LAUNCH_DISCOUNT_PERCENT / 100))} first month

{LAUNCH_DISCOUNT_PERCENT}% off · then {formatUSD(monthly)}/mo

) : (
{tier?.pricePrefix && ( {tier.pricePrefix} )} {priceLabel} /mo
)} {tier && (

{tier.credits}

Credits / month

{tier.description}

{tier.audience}

{tier.adds && (

Adds

{tier.adds}

)}
)}
{isEnterprise ? ( {ctaLabel || 'Contact Sales'} ) : isFreePlan ? ( ) : ctaDisabled && stripeSubscriptionStatus !== 'canceled' ? ( ) : ( )} {isFreeTrialActive && planKey === PlanType.HYPER_SCALING && (

Hyper Scaling is enabled during your free trial. Choose any plan to continue after your trial ends.

)}
); };