Spaces:
Sleeping
Sleeping
| 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> | |
| ) | |
| } | |