blob: c873eefa273de0e818c5c73837046cf038536e12 (
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
|
import React from "react";
import { Query } from "react-apollo";
import gql from "graphql-tag";
import { withStyles } from "@material-ui/core/styles";
import CircularProgress from "@material-ui/core/CircularProgress";
import BugSummary from "./BugSummary";
const QUERY = gql`
{
bugs: allBugs {
...BugSummary
}
}
${BugSummary.fragment}
`;
const styles = theme => ({
main: {
maxWidth: 600,
margin: "auto",
marginTop: theme.spacing.unit * 4
}
});
const List = withStyles(styles)(({ bugs, classes }) => (
<main className={classes.main}>
{bugs.map(bug => (
<BugSummary bug={bug} key={bug.id} />
))}
</main>
));
const ListPage = () => (
<Query query={QUERY}>
{({ loading, error, data }) => {
if (loading) return <CircularProgress />;
if (error) return <p>Error.</p>;
return <List bugs={data.bugs} />;
}}
</Query>
);
export default ListPage;
|