/** * StatsCards — KPI summary row: total vehicles, in-frame count, avg speed, uptime. */ export default function StatsCards({ latest, pipelineStatus }) { const cards = [ { label: 'Total Detected', value: latest?.total_count ?? '—', unit: 'vehicles', icon: '🚗', color: 'text-blue-400', }, { label: 'In Frame', value: latest?.vehicles_in_frame ?? '—', unit: 'active', icon: '📍', color: 'text-emerald-400', }, { label: 'Avg Speed', value: latest?.avg_speed_kmh != null ? latest.avg_speed_kmh.toFixed(1) : '—', unit: 'km/h', icon: '⚡', color: 'text-yellow-400', }, { label: 'Uptime', value: pipelineStatus?.uptime_seconds != null ? formatUptime(pipelineStatus.uptime_seconds) : '—', unit: '', icon: '🕒', color: 'text-purple-400', }, ] return (
{cards.map((c) => (
{c.icon} {c.label}
{c.value}
{c.unit && (
{c.unit}
)}
))}
) } function formatUptime(seconds) { const h = Math.floor(seconds / 3600) const m = Math.floor((seconds % 3600) / 60) const s = Math.floor(seconds % 60) if (h > 0) return `${h}h ${m}m` if (m > 0) return `${m}m ${s}s` return `${s}s` }