"use client"; import {Check} from "lucide-react"; import {useState} from "react"; import { annualSavingsPercent, type BillingPeriod, PRICING_TIERS, } from "@/lib/pricing"; const MAX_ANNUAL_SAVINGS = Math.max( ...PRICING_TIERS.map((t) => annualSavingsPercent(t)), ); export function PricingTiers() { const [period, setPeriod] = useState("annual"); return (
{/* Billing toggle */}
setPeriod("monthly")} > Monthly setPeriod("annual")} > Annual {MAX_ANNUAL_SAVINGS > 0 ? ( Save {MAX_ANNUAL_SAVINGS}% ) : null}
{PRICING_TIERS.map((tier) => { const isFree = tier.monthly === 0 && tier.annual === 0; const amount = period === "monthly" ? tier.monthly : tier.annual; const unit = period === "monthly" ? "/month" : "/year"; const isExternal = tier.cta.href.startsWith("http"); return (

{tier.name}

{tier.badge ? ( {tier.badge} ) : null}

{tier.tagline}

${amount} {!isFree ? ( {unit} ) : null}

{isFree ? tier.priceNote : period === "annual" ? tier.priceNote : `Billed monthly ยท ${tier.priceNote ?? ""}`}

{tier.cta.label}
    {tier.features.map((feature) => (
  • {feature}
  • ))}
); })}
); } function ToggleButton({ active, onClick, children, }: { active: boolean; onClick: () => void; children: React.ReactNode; }) { return ( ); }