"use client"; import { Button, buttonVariants } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { cn } from "@/lib/utils"; import { motion } from "framer-motion"; import { Star } from "lucide-react"; import { useState, useRef, useEffect } from "react"; import confetti from "canvas-confetti"; import NumberFlow from "@number-flow/react"; import { CheckIcon } from "@radix-ui/react-icons"; import { client } from "@/lib/auth-client"; function useMediaQuery(query: string) { const [matches, setMatches] = useState(false); useEffect(() => { const media = window.matchMedia(query); if (media.matches !== matches) { setMatches(media.matches); } const listener = () => setMatches(media.matches); media.addListener(listener); return () => media.removeListener(listener); }, [query]); return matches; } interface PricingPlan { name: string; price: string; yearlyPrice: string; period: string; features: string[]; description: string; buttonText: string; href: string; isPopular: boolean; } interface PricingProps { plans: PricingPlan[]; title?: string; description?: string; } export function Pricing({ plans, title = "Simple, Transparent Pricing", description = "Choose the plan that works for you", }: PricingProps) { const [isMonthly, setIsMonthly] = useState(true); const isDesktop = useMediaQuery("(min-width: 768px)"); const switchRef = useRef(null); const handleToggle = (checked: boolean) => { setIsMonthly(!checked); if (checked && switchRef.current) { const rect = switchRef.current.getBoundingClientRect(); const x = rect.left + rect.width / 2; const y = rect.top + rect.height / 2; confetti({ particleCount: 50, spread: 60, origin: { x: x / window.innerWidth, y: y / window.innerHeight, }, colors: [ "hsl(var(--primary))", "hsl(var(--accent))", "hsl(var(--secondary))", "hsl(var(--muted))", ], ticks: 200, gravity: 1.2, decay: 0.94, startVelocity: 30, shapes: ["circle"], }); } }; return (

{title}

{description}

Annual billing (Save 20%)
{plans.map((plan, index) => ( {plan.isPopular && (
Popular
)}

{plan.name}

{plan.period !== "Next 3 months" && ( / {plan.period} )}

{isMonthly ? "billed monthly" : "billed annually"}

    {plan.features.map((feature, idx) => (
  • {feature}
  • ))}

{plan.description}

))}
); }