// src/pages/agent-office/components/TaskTab.jsx import { useState, useEffect } from 'react'; import { getAgentTasks } from '../../../api'; const STATUS_STYLE = { succeeded: { bg: '#065f46', fg: '#34d399' }, failed: { bg: '#7f1d1d', fg: '#fca5a5' }, working: { bg: '#1e3a5f', fg: '#60a5fa' }, pending: { bg: '#92400e', fg: '#fbbf24' }, approved: { bg: '#065f46', fg: '#34d399' }, rejected: { bg: '#7f1d1d', fg: '#fca5a5' } }; function formatTime(ts) { if (!ts) return ''; const d = new Date(ts); const now = new Date(); const isToday = d.toDateString() === now.toDateString(); const time = d.toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit' }); return isToday ? time : `${d.getMonth() + 1}/${d.getDate()} ${time}`; } export default function TaskTab({ agentId, refreshTrigger }) { const [tasks, setTasks] = useState([]); const [expanded, setExpanded] = useState(null); useEffect(() => { let cancelled = false; getAgentTasks(agentId, 20).then(data => { if (!cancelled) setTasks(data || []); }); return () => { cancelled = true; }; }, [agentId, refreshTrigger]); return (
{(() => {
try { return JSON.stringify(JSON.parse(task.result_data), null, 2); }
catch { return task.result_data; }
})()}
)}