import Link from "next/link"; import { Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Badge, StatusBadge } from "@/components/ui/badge"; import { formatBytes, formatDate, formatMs, formatUsd, timeAgo } from "@/lib/format"; import type { RequestListRow } from "@/lib/queries/dashboard"; import { cn } from "@/lib/utils"; export function NetworkLabel({ network, requested }: { network: string | null; requested?: string }) { if (!network) return —; return ( {network === "isp" ? "ISP" : network} {requested && requested !== "auto" && requested !== network ? ( (asked {requested}) ) : null} ); } export function HttpCode({ code }: { code: number | null }) { if (code === null) return —; const tone = code < 300 ? "text-success" : code < 400 ? "text-info" : code < 500 ? "text-warning" : "text-danger"; return {code}; } /** Request log table. `compact` hides secondary columns (used on the Overview). */ export function RequestsTable({ rows, compact, emptyMessage = "No requests match these filters." }: { rows: RequestListRow[]; compact?: boolean; emptyMessage?: React.ReactNode }) { const cols = compact ? 7 : 11; return ( Request Time Domain Status HTTP {!compact ? Network : null} {!compact ? Country : null} Latency {!compact ? Attempts : null} {!compact ? Bandwidth : null} Cost {rows.length === 0 ? ( {emptyMessage} ) : ( rows.map((r) => ( {r.id} {r.source !== "api" ? ( {r.source} ) : null} {timeAgo(r.createdAt)} {r.domain} {!compact ? ( ) : null} {!compact ? {r.country ?? "—"} : null} {formatMs(r.latencyMs)} {!compact ? {r.attempts || "—"} : null} {!compact ? {formatBytes(r.bytesIn + r.bytesOut)} : null} {formatUsd(r.priceUsd, true)} )) )}
); }