({
isRunning,
isError,
startedAt,
completedAt,
}: StatusBadgeProps)
| 85 | } |
| 86 | |
| 87 | function StatusBadge({ |
| 88 | isRunning, |
| 89 | isError, |
| 90 | startedAt, |
| 91 | completedAt, |
| 92 | }: StatusBadgeProps) { |
| 93 | if (isRunning) { |
| 94 | return ( |
| 95 | <span className="flex items-center gap-1.5 text-xs text-brand-400"> |
| 96 | <Loader2 className="w-3.5 h-3.5 animate-spin" /> |
| 97 | <ElapsedTimer startMs={startedAt} /> |
| 98 | </span> |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | const duration = completedAt ? completedAt - startedAt : null; |
| 103 | const durationStr = duration |
| 104 | ? duration < 1000 |
| 105 | ? `${duration}ms` |
| 106 | : `${(duration / 1000).toFixed(1)}s` |
| 107 | : null; |
| 108 | |
| 109 | if (isError) { |
| 110 | return ( |
| 111 | <span className="flex items-center gap-1.5 text-xs text-red-400"> |
| 112 | <XCircle className="w-3.5 h-3.5" /> |
| 113 | {durationStr && <span>{durationStr}</span>} |
| 114 | <span>Error</span> |
| 115 | </span> |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | return ( |
| 120 | <span className="flex items-center gap-1.5 text-xs text-green-400"> |
| 121 | <CheckCircle2 className="w-3.5 h-3.5" /> |
| 122 | {durationStr && <span>{durationStr}</span>} |
| 123 | </span> |
| 124 | ); |
| 125 | } |
| 126 | |
| 127 | // ─── Main component ─────────────────────────────────────────────────────────── |
| 128 |
nothing calls this directly
no outgoing calls
no test coverage detected