/** 任務顯示組件 */ const TaskDisplay = ({ task, onCancel }) => { if (!task) return null; const getStatusColor = (status) => { switch (status) { case 'running': return 'bg-blue-100 text-blue-800'; case 'completed': return 'bg-green-100 text-green-800'; case 'cancelled': return 'bg-gray-100 text-gray-800'; case 'failed': return 'bg-red-100 text-red-800'; default: return 'bg-yellow-100 text-yellow-800'; } }; const getStatusText = (status) => { switch (status) { case 'pending': return '等待執行'; case 'running': return '執行中'; case 'completed': return '已完成'; case 'cancelled': return '已取消'; case 'failed': return '執行失敗'; default: return status; } }; const canCancel = task.status === 'pending' || task.status === 'running'; // 判斷任務類型(默認為台鐵以保持向後兼容) const isHSR = task.task_type === 'hsr'; // 遮罩身分證字號(只顯示前後各2位) const maskNationalId = (nationalId) => { if (!nationalId || nationalId.length < 4) { return nationalId; } return `${nationalId.substring(0, 2)}****${nationalId.substring(nationalId.length - 2)}`; }; return (

{isHSR ? '高鐵' : '台鐵'}訂票任務

{getStatusText(task.status)}
{isHSR ? ( // 高鐵任務顯示 <> {task.national_id && (
身分證: {maskNationalId(task.national_id)}
)}
日期: {task.departure_date || '未設定'}
路線: {task.start_position || '未設定'} → {task.end_position || '未設定'}
時間: {task.departure_time || '未設定'}
) : ( // 台鐵任務顯示 <>
日期: {task.date || '未設定'}
路線: {task.start_station?.split('-')[1] || task.start_station || '未設定'} → {task.end_station?.split('-')[1] || task.end_station || '未設定'}
時間: {task.start_time || '未設定'} ~ {task.end_time || '未設定'}
選項: {[ task.puyuma_only && '限普悠瑪', task.window && '靠窗', task.swap_seat && '同車換坐', task.t3k && '自強3000' ].filter(Boolean).join('、') || '預設'}
)} {task.message && (
{task.message}
)}
{canCancel && ( )}
); };