'use client'; import { Eye, XCircle, User, Box, Edit, Clock, FileText, Wallet } from 'lucide-react'; import { OrderDetail } from './OrderDetailModal'; import LocalTime from '@/components/common/LocalTime'; interface OrderTableProps { orders: OrderDetail[]; loading: boolean; onCancel: (orderId: string) => void; onViewDetail: (order: OrderDetail) => void; onEdit: (order: OrderDetail) => void; onCheckPayments: (order: OrderDetail) => void; // 新增:查看/核销支付记录 } export default function OrderTable({ orders, loading, onCancel, onViewDetail, onEdit, onCheckPayments }: OrderTableProps) { if (loading) { return (
加载订单数据中...
); } if (orders.length === 0) { return (
暂无订单记录
); } // 状态颜色映射 const getStatusColor = (status: string) => { switch (status) { case 'paid': return 'bg-green-100 text-green-800 border-green-200'; case 'succeeded': return 'bg-green-100 text-green-800 border-green-200'; case 'pending': return 'bg-yellow-100 text-yellow-800 border-yellow-200'; case 'cancelled': return 'bg-red-50 text-red-600 border-red-100'; case 'failed': return 'bg-red-100 text-red-800 border-red-200'; default: return 'bg-gray-100 text-gray-800 border-gray-200'; } }; // 辅助函数:是否可以取消 const canCancel = (status: string) => status !== 'cancelled' && status !== 'completed' && status !== 'failed'; return (
{/* =========================== */} {/* 1. Desktop View (Table) */} {/* =========================== */}
{orders.map((order) => ( ))}
订单号 / 创建时间 商品信息 用户信息 金额 状态 操作
{order.id}
{order.product_name || order.product_title || '未知商品'}
{order.user_name || order.applicant_name || '未填写'} {order.user_email || order.user_id}
{(order.base_amount / 100).toFixed(2)} {order.base_currency} {order.status}
{/* 待支付状态显示人工核销按钮 */} {order.status === 'pending' && ( )} {canCancel(order.status) && ( )}
{/* =========================== */} {/* 2. Mobile View (Cards) */} {/* =========================== */}
{orders.map((order) => (
{/* Header: ID & Status */}
{order.id}
{order.status.toUpperCase()}
{/* Info Grid */}
{/* Product */}
{order.product_name || order.product_title || '未知商品'}
{/* User & Price */}
申请人
{order.user_name || order.applicant_name || '-'}
金额
{(order.base_amount / 100).toFixed(2)} {order.base_currency}
{/* Actions */}
{order.status === 'pending' ? ( <> ) : ( <> )}
))}
); }