1import React from 'react';
2
3import CircularProgress from '@material-ui/core/CircularProgress';
4
5import { BugFragment } from './Bug.generated';
6import Timeline from './Timeline';
7import { useTimelineQuery } from './TimelineQuery.generated';
8
9type Props = {
10 bug: BugFragment;
11};
12
13const TimelineQuery = ({ bug }: Props) => {
14 const { loading, error, data } = useTimelineQuery({
15 variables: {
16 id: bug.id,
17 first: 100,
18 },
19 });
20
21 if (loading) return <CircularProgress />;
22 if (error) return <p>Error: {error}</p>;
23
24 const nodes = data?.repository?.bug?.timeline.nodes;
25 if (!nodes) {
26 return null;
27 }
28
29 return <Timeline ops={nodes} bug={bug} />;
30};
31
32export default TimelineQuery;