import { useRef, memo } from 'react'; import isEqual from 'react-fast-compare'; import { _array } from '@firecamp/utils'; import Table from '../primitive/Table'; import { ITableRows, TRenderCell, TTableApi, } from '../primitive/table.interfaces'; import { ITestResultTable } from './TestResultTable.interfaces'; const _columns = [ { id: 'status', key: 'status', name: 'Status', width: '100px', }, { id: 'name', key: 'name', name: 'Test Name', width: '200px', resizeWithContainer: true, }, ]; const TestResultTable = ({ rows = [], options = { allowRowAdd: false, allowRowRemove: false }, onChange = (rs: ITableRows) => {}, onMount = (api: TTableApi) => {}, }: ITestResultTable) => { const apiRef = useRef(); const renderCell: TRenderCell = ( column, cellValue, rowIndex, row, tableApi, onChange, handleDrag, options ) => { switch (column.id) { case 'status': return (
{row.isPassed ? 'PASS' : 'FAIL'}
); case 'name': return
{cellValue}
; default: return column.key; } }; return ( c.name} defaultRow={{ status: '', name: '', }} renderCell={renderCell} onChange={(rows) => { onChange(rows); }} onMount={(tApi) => { if (typeof onMount == 'function') { onMount(tApi); apiRef.current = tApi; } }} options={options} /> ); }; export default memo(TestResultTable, (p, n) => !isEqual(p, n));