'use client'; import { useState } from 'react'; import { Loader2, X, AlertTriangle } from 'lucide-react'; import { toast } from 'react-hot-toast'; 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()) { toast.error("请输入处理备注"); return; } setLoading(true); try { await onSubmit(ticketId, actionType, comment); setComment(''); toast.success('工单处理成功'); onClose(); } catch (error) { // ignore } finally { setLoading(false); } }; const config = { 'approve': { title: '批准退款申请', text: '确认核销批准' }, 'reject': { title: '驳回申请诉求', text: '确认驳回' }, 'need-info': { title: '要求申请人补件', text: '下发补件通知' }, }; const currentConfig = config[actionType]; return (
{/* Header */}
[ ACTION // #{ticketId} // {currentConfig.title} ]