import type { TopUserRow } from "../api/client";

export function TopUsersTable({ rows }: { rows: TopUserRow[] }) {
  if (rows.length === 0) {
    return <div className="chart-empty">Нет данных</div>;
  }
  return (
    <div style={{ overflowX: "auto" }}>
      <table className="stats-table">
        <thead>
          <tr>
            <th>Участник</th>
            <th>Тест</th>
            <th style={{ textAlign: "right" }}>Балл</th>
          </tr>
        </thead>
        <tbody>
          {rows.map((r, i) => (
            <tr key={i}>
              <td>{r.name}</td>
              <td className="poll-cell" title={r.poll}>
                {r.poll}
              </td>
              <td className="value-cell" style={{ textAlign: "right" }}>
                {r.value}
              </td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}
