1
- import React from " react" ;
2
- import { withStyles } from " @material-ui/core/styles" ;
3
- import Table from " @material-ui/core/Table" ;
4
- import TableBody from " @material-ui/core/TableBody" ;
5
- import TableCell from " @material-ui/core/TableCell" ;
6
- import TableHead from " @material-ui/core/TableHead" ;
7
- import TableRow from " @material-ui/core/TableRow" ;
8
- import Paper from " @material-ui/core/Paper" ;
9
- import DeleteIcon from " @material-ui/icons/Delete" ;
10
- import { IconButton } from " @material-ui/core" ;
1
+ import React from ' react' ;
2
+ import { withStyles } from ' @material-ui/core/styles' ;
3
+ import Table from ' @material-ui/core/Table' ;
4
+ import TableBody from ' @material-ui/core/TableBody' ;
5
+ import TableCell from ' @material-ui/core/TableCell' ;
6
+ import TableHead from ' @material-ui/core/TableHead' ;
7
+ import TableRow from ' @material-ui/core/TableRow' ;
8
+ import Paper from ' @material-ui/core/Paper' ;
9
+ import DeleteIcon from ' @material-ui/icons/Delete' ;
10
+ import { IconButton } from ' @material-ui/core' ;
11
11
12
12
const styles = ( theme : any ) => ( {
13
13
root : {
14
- width : " 80%" ,
15
- marginTop : theme . spacing . unit * 3
14
+ width : ' 80%' ,
15
+ marginTop : theme . spacing . unit * 3 ,
16
16
// overflowX: "auto"
17
17
} ,
18
18
table : {
19
- minWidth : 500
20
- }
19
+ minWidth : 500 ,
20
+ } ,
21
21
} ) ;
22
22
23
23
/** **************************
@@ -28,31 +28,25 @@ const styles = (theme: any) => ({
28
28
function dataTable ( props : any ) {
29
29
const { classes, rowData, rowHeader, deletePropHandler } = props ;
30
30
31
- const renderHeader = rowHeader . map ( ( col : any , idx : number ) => (
32
- < TableCell key = { `head_+${ idx } ` } > { col } </ TableCell >
33
- ) ) ;
31
+ const renderHeader = rowHeader . map ( ( col : any , idx : number ) => < TableCell key = { `head_+${ idx } ` } > { col } </ TableCell > ) ;
34
32
35
33
function renderRowCells ( row : any ) {
36
34
if ( ! row ) return ;
37
35
// for some reason we must put each value in a div.
38
36
return rowHeader . map ( ( header : string , idx : number ) => (
39
- < TableCell align = { " center" } key = { `td_${ idx } ` } >
37
+ < TableCell align = { ' center' } key = { `td_${ idx } ` } >
40
38
{ /* <div align={'center'} padding = {'none'} >{typeof row[header] === 'string' ? row[header] : row[header].toString()}</div> */ }
41
39
{ /* {row[header]} */ }
42
- { typeof row [ header ] === " string" ? row [ header ] : row [ header ] . toString ( ) }
40
+ { typeof row [ header ] === ' string' ? row [ header ] : row [ header ] . toString ( ) }
43
41
</ TableCell >
44
42
) ) ;
45
43
}
46
44
// style={{height: 30}}
47
45
const renderRows = rowData . map ( ( row : any ) => (
48
46
< TableRow key = { `row-${ row . id } ` } >
49
47
{ renderRowCells ( row ) }
50
- < TableCell align = { "center" } padding = { "none" } >
51
- < IconButton
52
- color = "default"
53
- fontSize = "small"
54
- onClick = { ( ) => deletePropHandler ( row . id ) }
55
- >
48
+ < TableCell align = { 'center' } padding = { 'none' } >
49
+ < IconButton color = "default" fontSize = "small" onClick = { ( ) => deletePropHandler ( row . id ) } >
56
50
< DeleteIcon />
57
51
</ IconButton >
58
52
{ /* <Button style={{height: 20}} onClick={() => deletePropHandler(row.id)}>Delete</Button> */ }
@@ -62,7 +56,7 @@ function dataTable(props: any) {
62
56
63
57
return (
64
58
< Paper className = { classes . root } >
65
- < Table className = { classes . table } selectable = { " true" } >
59
+ < Table className = { classes . table } selectable = { ' true' } >
66
60
< TableHead >
67
61
< TableRow > { renderHeader } </ TableRow >
68
62
</ TableHead >
0 commit comments