/** * Admin All Payments Page * View and manage all payment transactions */ import { useState, useEffect } from 'react'; import { Search, Filter, Loader2, AlertCircle } from 'lucide-react'; import { Card } from '../../components/ui/card'; import Badge from '../../components/ui/badge/Badge'; import { getAdminPayments, type Payment } from '../../services/billing.api'; type AdminPayment = Payment & { account_name?: string }; export default function AdminAllPaymentsPage() { const [payments, setPayments] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); const [statusFilter, setStatusFilter] = useState('all'); useEffect(() => { loadPayments(); }, []); const loadPayments = async () => { try { setLoading(true); const data = await getAdminPayments(); setPayments(data.results || []); } catch (err: any) { setError(err.message || 'Failed to load payments'); } finally { setLoading(false); } }; const filteredPayments = payments.filter((payment) => { return statusFilter === 'all' || payment.status === statusFilter; }); const getStatusColor = (status: string) => { switch (status) { case 'succeeded': case 'completed': return 'success'; case 'processing': case 'pending': case 'pending_approval': return 'warning'; case 'refunded': return 'info'; default: return 'error'; } }; if (loading) { return (
); } return (

All Payments

View and manage all payment transactions

{error && (

{error}

)}
{filteredPayments.length === 0 ? ( ) : ( filteredPayments.map((payment) => ( )) )}
Account Invoice Amount Method Status Date Actions
No payments found
{payment.account_name} {payment.invoice_number || payment.invoice_id || '—'} {payment.currency} {payment.amount} {payment.payment_method.replace('_', ' ')} {payment.status} {new Date(payment.created_at).toLocaleDateString()}
); }