All files / slow-app/src/components SlowDataTable.tsx

100% Statements 4/4
100% Branches 0/0
100% Functions 4/4
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                    3695x       29x                                                   3695x       1x                                                          
import type { PortfolioRow } from "../../../benchmark/src/data";
import { formatCurrency, formatPercent } from "../../../benchmark/src/data";
 
interface SlowDataTableProps {
  rows: readonly PortfolioRow[];
  selectedRowIds: readonly string[];
  onRowToggle: (id: string) => void;
}
 
function HealthBadge({ health }: { health: PortfolioRow["health"] }) {
  return <span className={`health-badge health-${health.toLowerCase()}`}>{health}</span>;
}
 
export function SlowDataTable({ rows, selectedRowIds, onRowToggle }: SlowDataTableProps) {
  return (
    <section className="panel table-panel" aria-labelledby="slow-table-title">
      <div className="panel-header">
        <div>
          <p className="eyebrow">Full DOM table</p>
          <h2 id="slow-table-title">Account portfolio</h2>
        </div>
        <span className="table-count">{rows.length.toLocaleString()} rows</span>
      </div>
      <div className="table-scroll" data-table-scroll="slow" tabIndex={0} aria-label="Scrollable full account table">
        <table>
          <thead>
            <tr>
              <th scope="col">Account</th>
              <th scope="col">Owner</th>
              <th scope="col">Region</th>
              <th scope="col">Tier</th>
              <th scope="col">Health</th>
              <th scope="col">ARR</th>
              <th scope="col">Conversion</th>
              <th scope="col">Latency</th>
              <th scope="col">Risk</th>
            </tr>
          </thead>
          <tbody>
            {rows.map((row) => (
              <tr
                key={row.id}
                data-testid="slow-row"
                aria-selected={selectedRowIds.includes(row.id)}
                onClick={() => onRowToggle(row.id)}
              >
                <td>
                  <span className="account-cell">
                    <img src={row.logoUrl} alt="" loading="eager" decoding="sync" />
                    <span>
                      <strong>{row.accountName}</strong>
                      <small>{row.id}</small>
                    </span>
                  </span>
                </td>
                <td>{row.owner}</td>
                <td>{row.region}</td>
                <td>{row.tier}</td>
                <td>
                  <HealthBadge health={row.health} />
                </td>
                <td>{formatCurrency(row.annualContractValue)}</td>
                <td>{formatPercent(row.conversionRate)}</td>
                <td>{row.latencyMs} ms</td>
                <td>{row.riskScore}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    </section>
  );
}