"use client" import { useState } from "react" import { cn } from "@/lib/utils" export function CheckoutButton({ plan, label, highlight }: { plan: string; label: string; highlight?: boolean }) { const [loading, setLoading] = useState(false) async function handleClick() { setLoading(true) const res = await fetch("/api/stripe/checkout", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ plan }), }) const data = await res.json() if (data.url) window.location.href = data.url else setLoading(false) } return ( ) }