import type { HttpExchange, ProxyHeader } from '@yaakapp-internal/proxy-lib'; import { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow, TruncatedWideTableCell, } from '@yaakapp-internal/ui'; import classNames from 'classnames'; interface Props { exchanges: HttpExchange[]; style?: React.CSSProperties; className?: string; } export function ExchangesTable({ exchanges, style, className }: Props) { if (exchanges.length === 0) { return

No traffic yet

; } return (
Method URL Status Type {exchanges.map((ex) => ( {ex.method} {ex.url} {getContentType(ex.resHeaders)} ))}
); } function StatusBadge({ status, error }: { status: number | null; error: string | null }) { if (error) return Error; if (status == null) return ; const color = status >= 500 ? 'text-danger' : status >= 400 ? 'text-warning' : status >= 300 ? 'text-notice' : 'text-success'; return {status}; } function getContentType(headers: ProxyHeader[]): string { const ct = headers.find((h) => h.name.toLowerCase() === 'content-type')?.value; if (ct == null) return '—'; // Strip parameters (e.g. "; charset=utf-8") return ct.split(';')[0]?.trim() ?? ct; }