/** 任務列表組件 */ const TaskList = ({ tasks, currentTaskId, onCancel, onRemove }) => { if (!tasks || tasks.length === 0) { return null; } const getStatusColor = (status) => { switch (status) { case 'running': return 'bg-blue-100 text-blue-800 border-blue-500'; case 'pending': return 'bg-yellow-100 text-yellow-800 border-yellow-500'; case 'completed': return 'bg-green-100 text-green-800 border-green-500'; case 'cancelled': return 'bg-gray-100 text-gray-800 border-gray-500'; case 'failed': return 'bg-red-100 text-red-800 border-red-500'; default: return 'bg-gray-100 text-gray-800 border-gray-500'; } }; const getStatusText = (status) => { switch (status) { case 'pending': return '等待中'; case 'running': return '執行中'; case 'completed': return '已完成'; case 'cancelled': return '已取消'; case 'failed': return '執行失敗'; default: return status; } }; // 計算等待中的任務位置 const getPendingPosition = (task, allTasks) => { if (task.status !== 'pending') { return null; } const pendingTasks = allTasks.filter(t => t.status === 'pending'); const index = pendingTasks.findIndex(t => t.task_id === task.task_id); return index >= 0 ? index + 1 : null; }; return (

任務列表

{tasks.map((task) => { const isRunning = task.task_id === currentTaskId; const isHSR = task.task_type === 'hsr'; const pendingPosition = getPendingPosition(task, tasks); // 遮罩身分證字號 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)} {pendingPosition && ( (#{pendingPosition}) )}
{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.note && (
備註: {task.note}
)} {task.message && (
{task.message}
)}
{(task.status === 'pending' || task.status === 'running') && ( <> {task.status === 'running' && ( )} {task.status === 'pending' && ( )} )}
); })}
); };