1import React from 'react';
2
3import { Link } from '@material-ui/core';
4import CircularProgress from '@material-ui/core/CircularProgress';
5
6import { useGetBugsByUserQuery } from './GetBugsByUser.generated';
7
8type Props = {
9 humanId: string;
10};
11
12function BugList({ humanId }: Props) {
13 const { loading, error, data } = useGetBugsByUserQuery({
14 variables: {
15 query: 'author:' + humanId,
16 },
17 });
18
19 if (loading) return <CircularProgress />;
20 if (error) return <p>Error: {error}</p>;
21 const bugs = data?.repository?.allBugs.nodes;
22
23 console.log(bugs);
24 return (
25 <ol>
26 <li>{bugs ? bugs[0].title : ''}</li>
27 <Link href={'/bug/' + (bugs ? bugs[0].id : '')}>Klick</Link>
28 </ol>
29 );
30}
31
32export default BugList;