gui-sparim's picture
Upload 69 files
010c33f verified
raw
history blame contribute delete
885 Bytes
import React from 'react'
export default function DataTable({ table, maxHeight = 320 }) {
if (!table || !table.columns || !table.rows) {
return <div className="empty-box">Sem dados.</div>
}
return (
<div className="table-wrapper" style={{ maxHeight }}>
<table>
<thead>
<tr>
{table.columns.map((col) => (
<th key={col}>{col}</th>
))}
</tr>
</thead>
<tbody>
{table.rows.map((row, i) => (
<tr key={i}>
{table.columns.map((col) => (
<td key={`${i}-${col}`}>{String(row[col] ?? '')}</td>
))}
</tr>
))}
</tbody>
</table>
{table.truncated ? (
<div className="table-hint">Mostrando {table.returned_rows} de {table.total_rows} linhas.</div>
) : null}
</div>
)
}