1import React from 'react';
2import { RouteComponentProps } from 'react-router-dom';
3
4import CircularProgress from '@material-ui/core/CircularProgress';
5
6import { useGetUserByIdQuery } from '../../components/Identity/UserIdentity.generated';
7
8import Identity from './Identity';
9
10type Props = RouteComponentProps<{
11 id: string;
12}>;
13
14const UserQuery: React.FC<Props> = ({ match }: Props) => {
15 const { loading, error, data } = useGetUserByIdQuery({
16 variables: { userId: match.params.id },
17 });
18 if (loading) return <CircularProgress />;
19 if (error) return <p>Error: {error}</p>;
20 if (!data?.repository?.identity) return <p>404.</p>;
21 return <Identity identity={data.repository.identity} />;
22};
23
24export default UserQuery;