From 644d9dbf32a5a517268b2759d0763639b7677d14 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 29 Apr 2021 19:09:03 +0100 Subject: [PATCH] Update auth route component --- src/components/AuthRoute/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/AuthRoute/index.tsx b/src/components/AuthRoute/index.tsx index 89e5af8..090ed3e 100644 --- a/src/components/AuthRoute/index.tsx +++ b/src/components/AuthRoute/index.tsx @@ -1,12 +1,18 @@ import { useReactiveVar } from '@apollo/client'; import { Redirect, Route, RouteProps } from 'react-router-dom'; -import { tokenVar } from '../../graphql/state'; +import { tokenVar, userVar } from '../../graphql/state'; const AuthRoute: React.FC = ({ children, ...rest }) => { const token = useReactiveVar(tokenVar); + const user = useReactiveVar(userVar); return ( - (!token ? children : )} /> + + !token || !user?.firstName ? children : + } + /> ); };