From 29ea8df4259921f1789e0e6d584767fc5f54b284 Mon Sep 17 00:00:00 2001 From: Cláudio Date: Fri, 5 Feb 2021 19:36:09 -0300 Subject: Commit for #541 --- webui/src/components/IfLoggedIn/IfLoggedIn.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 webui/src/components/IfLoggedIn/IfLoggedIn.tsx (limited to 'webui/src/components/IfLoggedIn') diff --git a/webui/src/components/IfLoggedIn/IfLoggedIn.tsx b/webui/src/components/IfLoggedIn/IfLoggedIn.tsx new file mode 100644 index 00000000..2476aad8 --- /dev/null +++ b/webui/src/components/IfLoggedIn/IfLoggedIn.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import { useCurrentIdentityQuery } from '../CurrentIdentity/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; -- cgit