import React from 'react'; import { Button } from '../ui/button'; import StatusBadge from '../StatusBadge'; import { ChevronDown, ChevronUp, Edit, XCircle, CreditCard, Info, ExternalLink, Copy } from 'lucide-react'; const HEADER_CELLS = [ { label: 'Member', align: 'text-left' }, { label: 'Plan', align: 'text-left' }, { label: 'Status', align: 'text-left' }, { label: 'Period', align: 'text-left' }, { label: 'Base Fee', align: 'text-right' }, { label: 'Donation', align: 'text-right' }, { label: 'Total', align: 'text-right' }, { label: 'Details', align: 'text-center' }, { label: 'Actions', align: 'text-center' } ]; const HeaderCell = ({ align, children }) => ( {children} ); const TableCell = ({ align = 'text-left', className = '', style, children, ...props }) => ( {children} ); const SubscriptionRow = ({ sub, isExpanded, onToggle, onEdit, onCancel, hasPermission, formatDate, formatDateTime, formatPrice, copyToClipboard }) => ( <>
{sub.user.first_name} {sub.user.last_name}
{sub.user.email}
{sub.plan.name}
{sub.plan.billing_cycle}
{formatDate(sub.start_date)}
to {formatDate(sub.end_date)}
{formatPrice(sub.base_subscription_cents || 0)} {formatPrice(sub.donation_cents || 0)} {formatPrice(sub.amount_paid_cents || 0)}
{hasPermission('subscriptions.edit') && ( )} {sub.status === 'active' && hasPermission('subscriptions.cancel') && ( )}
{isExpanded && (

Transaction Details

Payment Information
{sub.payment_completed_at && (
Payment Date: {formatDateTime(sub.payment_completed_at)}
)} {sub.payment_method && (
Payment Method: {sub.payment_method}
)} {sub.card_brand && sub.card_last4 && (
Card: {sub.card_brand} ****{sub.card_last4}
)}
Stripe Transaction IDs
{sub.stripe_payment_intent_id && (
Payment Intent:
{sub.stripe_payment_intent_id.substring(0, 20)}...
)} {sub.stripe_charge_id && (
Charge ID:
{sub.stripe_charge_id.substring(0, 20)}...
)} {sub.stripe_subscription_id && (
Subscription ID:
{sub.stripe_subscription_id.substring(0, 20)}...
)} {sub.stripe_invoice_id && (
Invoice ID:
{sub.stripe_invoice_id.substring(0, 20)}...
)} {sub.stripe_customer_id && (
Customer ID:
{sub.stripe_customer_id.substring(0, 20)}...
)} {sub.stripe_receipt_url && (
Receipt:
)}
)} ); const SubscriptionsTable = ({ subscriptions, expandedRows, onToggleRowExpansion, onEdit, onCancel, hasPermission, formatDate, formatDateTime, formatPrice, copyToClipboard }) => ( {HEADER_CELLS.map((cell) => ( {cell.label} ))} {subscriptions.length > 0 ? ( subscriptions.map((sub) => ( onToggleRowExpansion(sub.id)} onEdit={onEdit} onCancel={onCancel} hasPermission={hasPermission} formatDate={formatDate} formatDateTime={formatDateTime} formatPrice={formatPrice} copyToClipboard={copyToClipboard} /> )) ) : ( No subscriptions found )}
); export default SubscriptionsTable;