blob: 54b2fe9721866844f491974705b4f700256da437 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import { makeStyles } from '@material-ui/styles';
import IconButton from '@material-ui/core/IconButton';
import Table from '@material-ui/core/Table/Table';
import TableBody from '@material-ui/core/TableBody/TableBody';
import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft';
import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight';
import React from 'react';
import BugRow from './BugRow';
const useStyles = makeStyles(theme => ({
main: {
maxWidth: 600,
margin: 'auto',
marginTop: theme.spacing(4),
},
pagination: {
...theme.typography.overline,
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
},
}));
function List({ bugs, nextPage, prevPage }) {
const classes = useStyles();
const { hasNextPage, hasPreviousPage } = bugs.pageInfo;
return (
<main className={classes.main}>
<Table className={classes.table}>
<TableBody>
{bugs.edges.map(({ cursor, node }) => (
<BugRow bug={node} key={cursor} />
))}
</TableBody>
</Table>
<div className={classes.pagination}>
<div>Total: {bugs.totalCount}</div>
<IconButton onClick={prevPage} disabled={!hasPreviousPage}>
<KeyboardArrowLeft />
</IconButton>
<IconButton onClick={nextPage} disabled={!hasNextPage}>
<KeyboardArrowRight />
</IconButton>
</div>
</main>
);
}
export default List;
|