'use client' import { useState } from 'react' import { useRouter, useSearchParams } from 'next/navigation' import { motion } from 'framer-motion' import { TRAFFIC_TIERS, PLAN_PRICES, } from '@/lib/plans' interface PlanSummaryProps { plan: string interval: string limit: number } export default function PlanSummary({ plan, interval, limit }: PlanSummaryProps) { const router = useRouter() const searchParams = useSearchParams() const [currentInterval, setCurrentInterval] = useState(interval) const monthlyCents = PLAN_PRICES[plan]?.[limit] || 0 const isYearly = currentInterval === 'year' const displayPrice = isYearly ? (monthlyCents * 11) / 100 : monthlyCents / 100 const monthlyEquivalent = isYearly ? displayPrice / 12 : displayPrice const tierLabel = TRAFFIC_TIERS.find((t) => t.value === limit)?.label || `${(limit / 1000).toFixed(0)}k` const handleIntervalToggle = (newInterval: string) => { setCurrentInterval(newInterval) const params = new URLSearchParams(searchParams.toString()) params.set('interval', newInterval) router.replace(`/checkout?${params.toString()}`, { scroll: false }) } return (
{/* Plan name + badge */}

{plan}

30-day trial
{/* Interval toggle */}
{(['month', 'year'] as const).map((iv) => ( ))}
{/* Price row */}
€{isYearly ? monthlyEquivalent.toFixed(2) : displayPrice.toFixed(0)} /mo · {tierLabel} pageviews {isYearly && ( Save 1 month )}
{isYearly && (

€{displayPrice.toFixed(2)} billed yearly

)}
) }