"use client"; import { Fragment, useState } from "react"; import Link from "next/link"; import { useTranslations } from "next-intl"; import { PricingAnimatedPrice } from "@/components/sections/PricingAnimatedPrice"; import { PricingBillingToggle } from "@/components/sections/PricingBillingToggle"; import { PricingCheckoutButton } from "@/components/sections/PricingCheckoutButton"; import { PricingCompareFeatureLabel, PricingCompareValueCell, PricingCompareValueInline, } from "@/components/sections/PricingCompareValue"; import type { BillingPeriod, PricingTier } from "@/components/sections/pricing-data"; import { COMPARE_ANNUAL_SAVINGS_BADGE, COMPARE_SECTIONS, getCompareAtPrice, getDisplayPrice, PRICING_TIERS, } from "@/components/sections/pricing-data"; import { Button } from "@/components/ui/button"; import type { PaidPlanId } from "@/lib/plans"; import { cn } from "@/lib/utils"; interface PricingCompareTableProps { billing: BillingPeriod; onBillingChange: (billing: BillingPeriod) => void; } function SavingsArrowIcon() { return ( ); } function PlanHeaderCell({ tier, billing, }: { tier: PricingTier; billing: BillingPeriod; }) { const t = useTranslations("auto.componentsSectionsPricingCompareTable"); const highlighted = tier.highlighted ?? false; const isStripePlan = tier.id === "pro" || tier.id === "business"; return ( {highlighted ? ( {t("mostPopular")} ) : ( )}

{tier.name}

{isStripePlan ? ( ) : ( )} ); } export function PricingCompareTable({ billing, onBillingChange, }: PricingCompareTableProps) { const t = useTranslations("auto.componentsSectionsPricingCompareTable"); const lite = PRICING_TIERS.find((t) => t.id === "lite"); const pro = PRICING_TIERS.find((t) => t.id === "pro"); const business = PRICING_TIERS.find((t) => t.id === "business"); if (!lite || !pro || !business) return null; return ( <> {/* Mobile: one plan at a time (tabs) — the wide table can't fit a phone. */} {/* Desktop: full comparison table */}
{COMPARE_SECTIONS.map((section) => ( {section.rows.map((row) => ( ))} ))}

{t("compareHeading")}

{t("saveUpTo", { percent: COMPARE_ANNUAL_SAVINGS_BADGE })}

{section.title}
); } const TIER_IDS = ["lite", "pro", "business"] as const; type CompareTierId = (typeof TIER_IDS)[number]; function MobileCompare({ billing, onBillingChange, }: PricingCompareTableProps) { const t = useTranslations("auto.componentsSectionsPricingCompareTable"); const [active, setActive] = useState("pro"); const tier = PRICING_TIERS.find((x) => x.id === active); if (!tier) return null; const isStripePlan = tier.id === "pro" || tier.id === "business"; return (

{t("compareHeading")}

{/* Plan tabs */}
{TIER_IDS.map((id) => { const x = PRICING_TIERS.find((p) => p.id === id); if (!x) return null; return ( ); })}
{/* Selected plan price + CTA */}
{isStripePlan ? ( ) : ( )}
{/* Feature sections for the selected plan */}
{COMPARE_SECTIONS.map((section) => (

{section.title}

{section.rows.map((row) => (
))}
))}
); }