aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/layout/IfLoggedIn.tsx
blob: 8b9058dcc6b32c575082d51a86207a0e362dc9ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import React from 'react';

import { useCurrentIdentityQuery } from './CurrentIdentity.generated';

type Props = { children: React.ReactNode };
const IfLoggedIn = ({ children }: Props) => {
  const { loading, error, data } = useCurrentIdentityQuery();

  if (error || loading || !data?.repository?.userIdentity) return null;

  return <>{children}</>;
};

export default IfLoggedIn;