import Link from 'next/link'; import type { ReactNode } from 'react'; import { RunStatusPill, fmtDuration } from '@/components/meta/connectors-table'; import { cn } from '@/lib/cn'; import { fmtAgo, fmtDateTime, fmtInt, num } from '@/lib/format'; import type { ConnectorRun } from './types'; /** Server-safe admin building blocks: page header, stat tiles, error state, byte formatting, runs table. */ export function fmtBytes(v: number | string | null | undefined): string { const n = num(v); if (n === null) return '—'; if (n < 1024) return `${fmtInt(n)} B`; const units = ['KB', 'MB', 'GB', 'TB']; let x = n / 1024; let i = 0; while (x >= 1024 && i < units.length - 1) { x /= 1024; i++; } return `${x >= 100 ? x.toFixed(0) : x.toFixed(1)} ${units[i]}`; } export function AdminHeader({ title, lede, action }: { title: ReactNode; lede?: ReactNode; action?: ReactNode }) { return (
Admin
{lede}
}{what} unavailable
{message}
{label}
{value}
{hint &&{hint}
} > ); return href ? ( {body} ) : ({emptyLabel}
; return (| Connector | }Started | Status | Duration | Fetched | Created | Updated | Error |
|---|---|---|---|---|---|---|---|
| {r.connector_name} | )}{fmtAgo(r.started_at, now)} {fmtDateTime(r.started_at)} |
|
{fmtDuration(r.duration_ms)} | {fmtInt(r.records_fetched)} | {fmtInt(r.records_created)} | {fmtInt(r.records_updated)} | {r.error ? ( {r.error} ) : ( — )} |
{JSON.stringify(value)};
}