2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
import { useState, useEffect} from 'react';
|
|
|
|
import MaterialTable from 'material-table';
|
|
|
|
import Modal from '../Modal'
|
|
|
|
import { render } from '@testing-library/react';
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
import React from 'react';
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
const MTable = (props) => {
|
|
|
|
|
|
|
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
console.log('rederizou....................: ',props.data)
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
console.log(`You have clicked the button ${selectedRow} times`)
|
|
|
|
|
|
|
|
},[selectedRow]);
|
|
|
|
|
|
|
|
return ( <div style={{ maxWidth: "100%", fontSize:10}}>
|
|
|
|
|
|
|
|
<MaterialTable
|
|
|
|
title='Relatorio'
|
|
|
|
columns={props.columns}
|
|
|
|
data={props.data}
|
|
|
|
|
|
|
|
onRowClick={(evt, selectedRow) => {
|
|
|
|
|
|
|
|
console.log(selectedRow.tableData.id);
|
|
|
|
console.log(selectedRow);
|
|
|
|
console.log(selectedRow.messages);
|
|
|
|
setSelectedRow(selectedRow.tableData.id)
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
render(<Modal data={selectedRow.messages}/>)
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
//evt.stopPropagation()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
options={{
|
|
|
|
search: true,
|
|
|
|
selection: false,
|
|
|
|
paging: false,
|
|
|
|
searchFieldStyle: {
|
|
|
|
width: 300,
|
|
|
|
},
|
|
|
|
|
|
|
|
rowStyle: rowData => ({
|
|
|
|
fontSize: 12,
|
|
|
|
backgroundColor:
|
|
|
|
selectedRow === rowData.tableData.id ? '#ec5114' : '#FFF'
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
|
|
|
|
export default React.memo(MTable)
|