"use client"; import { CreditCard } from "lucide-react"; import { useEffect, useState } from "react"; import { Button } from "../../../../../shadcnui"; import { PaymentMethodInterface, StripeCustomerService } from "../../data"; import { PaymentMethodEditor } from "../forms/PaymentMethodEditor"; import { PaymentMethodsList } from "../lists/PaymentMethodsList"; export function PaymentMethodsContainer() { const [paymentMethods, setPaymentMethods] = useState([]); const [loading, setLoading] = useState(true); const [showAddPaymentMethod, setShowAddPaymentMethod] = useState(false); const loadPaymentMethods = async () => { setLoading(true); try { const fetchedPaymentMethods = await StripeCustomerService.listPaymentMethods(); setPaymentMethods(fetchedPaymentMethods); } catch (error) { console.error("[PaymentMethodsContainer] Failed to load payment methods:", error); } finally { setLoading(false); } }; useEffect(() => { loadPaymentMethods(); }, []); if (loading) { return (

Loading payment methods...

); } return (
{/* Header */}

Payment Methods

{/* Empty State */} {paymentMethods.length === 0 && (

No payment methods

Add a payment method to enable subscriptions and secure checkout.

)} {/* Payment Methods List */} {paymentMethods.length > 0 && ( )} {/* Add Payment Method Modal */} {showAddPaymentMethod && ( )}
); }