'use client' // 2026-04-26 P2.5 by Claude — AIOps Timeline // ============================================================ // EvidenceViewer — 8D evidence 視覺化 // Tab 切換不同 dimension,每個 dimension 顯示狀態 + 詳情 // ============================================================ import { useState } from 'react' import { useTranslations } from 'next-intl' import { CheckCircle2, AlertTriangle, HelpCircle } from 'lucide-react' import { cn } from '@/lib/utils' import type { EvidenceDimension } from './types' interface EvidenceViewerProps { dimensions: EvidenceDimension[] } const DIMENSION_STATUS_CONFIG = { ok: { icon: CheckCircle2, color: 'text-status-healthy', bg: 'bg-status-healthy/10', label: 'OK' }, anomaly: { icon: AlertTriangle, color: 'text-status-critical', bg: 'bg-status-critical/10', label: 'ANOMALY' }, unknown: { icon: HelpCircle, color: 'text-nothing-gray-400', bg: 'bg-nothing-gray-100', label: 'UNKNOWN' }, } export function EvidenceViewer({ dimensions }: EvidenceViewerProps) { const t = useTranslations('aiopsTimeline') const [activeTab, setActiveTab] = useState(0) const active = dimensions[activeTab] return (
{/* Tab nav — 8 個 dimension 可滾動 */}
{dimensions.map((dim, i) => { const cfg = DIMENSION_STATUS_CONFIG[dim.status] return ( ) })}
{/* Active dimension detail */} {active && (
{(() => { const cfg = DIMENSION_STATUS_CONFIG[active.status] return ( <> {cfg.label} ) })()}

{active.name}

{active.detail && (

{active.detail}

)}
{active.value !== null && active.value !== undefined ? String(active.value) : t('evidence.noData')}
)} {/* Summary row: anomaly count */}
{t('evidence.anomalyCount', { count: dimensions.filter(d => d.status === 'anomaly').length, total: dimensions.length, })} {/* Mini status dots */}
{dimensions.map((d, i) => (
))}
) }