-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f94017b
commit 460f40e
Showing
2 changed files
with
77 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react' | ||
import { withStyles, makeStyles } from '@material-ui/core/styles' | ||
import Table from '@material-ui/core/Table' | ||
import TableBody from '@material-ui/core/TableBody' | ||
import TableCell from '@material-ui/core/TableCell' | ||
import TableContainer from '@material-ui/core/TableContainer' | ||
import TableHead from '@material-ui/core/TableHead' | ||
import TableRow from '@material-ui/core/TableRow' | ||
import Paper from '@material-ui/core/Paper' | ||
|
||
const StyledTableCell = withStyles((theme) => ({ | ||
head: { | ||
backgroundColor: theme.palette.common.black, | ||
color: theme.palette.common.white, | ||
}, | ||
body: { | ||
fontSize: 14, | ||
}, | ||
}))(TableCell) | ||
|
||
const StyledTableRow = withStyles((theme) => ({ | ||
root: { | ||
'&:nth-of-type(odd)': { | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
}, | ||
}))(TableRow) | ||
|
||
function createData({ name, email, score }) { | ||
return { name, email, score } | ||
} | ||
|
||
// const rows = [ | ||
// createData('Frozen yoghurt', 159, 6.0), | ||
// createData('Ice cream sandwich', 237, 9.0), | ||
// createData('Eclair', 262, 16.0), | ||
// createData('Cupcake', 305, 3.7), | ||
// createData('Gingerbread', 356, 16.0), | ||
// ] | ||
|
||
const useStyles = makeStyles({ | ||
table: { | ||
minWidth: 500, | ||
}, | ||
}) | ||
|
||
export default function ResponsesTable({ responses }) { | ||
const classes = useStyles() | ||
const rows = responses.map((resp) => createData(resp)) | ||
return ( | ||
<TableContainer component={Paper}> | ||
<Table className={classes.table} aria-label='customized table'> | ||
<TableHead> | ||
<TableRow> | ||
<StyledTableCell>Name</StyledTableCell> | ||
<StyledTableCell align='center'>Email Address</StyledTableCell> | ||
<StyledTableCell align='right'>Score</StyledTableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row) => ( | ||
<StyledTableRow key={row.name}> | ||
<StyledTableCell component='th' scope='row'> | ||
{row.name} | ||
</StyledTableCell> | ||
<StyledTableCell align='center'>{row.email}</StyledTableCell> | ||
<StyledTableCell align='right'>{row.score}</StyledTableCell> | ||
</StyledTableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters