import React from "react" ; import { Route , Redirect } from "react-router-dom" ; import { useAuthContext } from "contexts/AuthContext" ; import { ConvoyChatLoader } from "@convoy-ui" ; interface AuthRouteProps { component : Function ; [ x ] : any ; } const AuthRoute = ( { component : Component , ... rest } ) => { const { isAuthenticated , isLoading } = useAuthContext ( ) ; return ( < Route { ... rest } render = { props => isLoading ? ( < ConvoyChatLoader />) : isAuthenticated ? (<Component {...props}/ > ) : ( < Redirect to = { { pathname : "/login" , state : { from : props . location } } } />)}/ > ) ; } ; export default AuthRoute ;