"use client"; import { useState } from "react"; interface PaymentButtonProps { planId: string; planType: "setup" | "monthly"; label: string; variant?: "primary" | "secondary"; } export default function PaymentButton({ planId, planType, label, variant = "primary" }: PaymentButtonProps) { const [loading, setLoading] = useState(false); const [email, setEmail] = useState(""); const [showModal, setShowModal] = useState(false); const handleCheckout = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { const response = await fetch("/api/stripe/checkout", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ planId, planType, email, }), }); const data = await response.json(); if (data.url) { window.location.href = data.url; } else { alert("Error initiating checkout. Please try again."); } } catch (error) { console.error("Checkout error:", error); alert("Error initiating checkout. Please try again."); } finally { setLoading(false); } }; const buttonClass = variant === "primary" ? "bg-brand-pink hover:bg-[#ff7bc0]" : "border border-white/20 hover:bg-white/10"; return ( <> {showModal && (

Enter your email to continue

We'll send the payment link to your email.

setEmail(e.target.value)} className="w-full px-4 py-3 rounded-lg bg-white/10 border border-white/20 text-white placeholder:text-white/40 focus:outline-none focus:border-brand-pink mb-4" />
)} ); }