'use client'; import { useState, useEffect } from 'react'; interface RefundDialogProps { orderId: string; amount: number; onConfirm: (reason: string, force: boolean) => Promise; onCancel: () => void; warning?: string; requireForce?: boolean; dark?: boolean; } export default function RefundDialog({ orderId, amount, onConfirm, onCancel, warning, requireForce, dark = false, }: RefundDialogProps) { const [reason, setReason] = useState(''); const [force, setForce] = useState(false); const [loading, setLoading] = useState(false); useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onCancel(); }; document.addEventListener('keydown', handleKeyDown); return () => document.removeEventListener('keydown', handleKeyDown); }, [onCancel]); const handleConfirm = async () => { setLoading(true); try { await onConfirm(reason, force); } finally { setLoading(false); } }; return (
e.stopPropagation()} >

确认退款

订单号
{orderId}
退款金额
¥{amount.toFixed(2)}
{warning && (
{warning}
)}
setReason(e.target.value)} placeholder="请输入退款原因(可选)" className={[ 'w-full rounded-lg border px-3 py-2 text-sm focus:border-blue-500 focus:outline-none', dark ? 'border-slate-600 bg-slate-800 text-slate-100' : 'border-gray-300 bg-white text-gray-900', ].join(' ')} />
{requireForce && ( )}
); }