import PropTypes from 'prop-types' import { TableContainer, Table, TableHead, TableCell, TableRow, TableBody, Paper, Chip, Stack, Typography } from '@mui/material' import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser' export const TableViewOnly = ({ columns, rows, sx }) => { // Helper function to safely render cell content const renderCellContent = (key, row) => { if (row[key] === null || row[key] === undefined) { return '' } else if (key === 'enabled') { return row[key] ? : } else if (key === 'type' && row.schema) { // If there's schema information, add a tooltip let schemaContent if (Array.isArray(row.schema)) { // Handle array format: [{ name: "field", type: "string" }, ...] schemaContent = '[
' + row.schema .map( (item) => `  ${JSON.stringify( { [item.name]: item.type }, null, 2 )}` ) .join(',
') + '
]' } else if (typeof row.schema === 'object' && row.schema !== null) { // Handle object format: { "field": "string", "field2": "number", ... } schemaContent = JSON.stringify(row.schema, null, 2).replace(/\n/g, '
').replace(/ /g, ' ') } else { schemaContent = 'No schema available' } return ( {row[key]} Schema:
${schemaContent}`} />
) } else if (typeof row[key] === 'object') { // For other objects (that are not handled by special cases above) return JSON.stringify(row[key]) } else { return row[key] } } return ( <> {columns.map((col, index) => ( {col === 'enabled' ? ( <> Override ) : ( col.charAt(0).toUpperCase() + col.slice(1) )} ))} {rows.map((row, index) => ( {Object.keys(row).map((key, index) => { if (key !== 'id' && key !== 'schema') { return {renderCellContent(key, row)} } })} ))}
) } TableViewOnly.propTypes = { rows: PropTypes.array, columns: PropTypes.array, sx: PropTypes.object }