'use client'; import { useState } from 'react'; import { Loader2, X } from 'lucide-react'; import { ActionType } from '@/types'; interface TicketActionModalProps { isOpen: boolean; onClose: () => void; ticketId: number | null; actionType: ActionType | null; onSubmit: (ticketId: number, type: ActionType, comment: string) => Promise; } export default function TicketActionModal({ isOpen, onClose, ticketId, actionType, onSubmit }: TicketActionModalProps) { const [comment, setComment] = useState(''); const [loading, setLoading] = useState(false); if (!isOpen || !ticketId || !actionType) return null; const handleSubmit = async () => { if (!comment.trim()) { alert("请输入处理备注"); return; } setLoading(true); try { await onSubmit(ticketId, actionType, comment); setComment(''); // 清空 onClose(); // 关闭 } catch (error) { // 错误由父组件处理或在这里处理 } finally { setLoading(false); } }; const config = { 'approve': { title: '批准退款', btnColor: 'bg-green-600 hover:bg-green-700', text: '确认批准' }, 'reject': { title: '拒绝申请', btnColor: 'bg-red-600 hover:bg-red-700', text: '确认拒绝' }, 'need-info': { title: '要求补充资料', btnColor: 'bg-orange-500 hover:bg-orange-600', text: '发送请求' }, }; const currentConfig = config[actionType]; return (

{currentConfig.title} (工单 #{ticketId})