Rajiv
Deploy to Hugging Face
e7c08a9
Raw
History Blame Contribute Delete
785 Bytes
import { useAuth } from "../hooks/useAuth";
import { Navigate } from "react-router";
import React from 'react'
const Protected = ({children}) => {
const { loading,user } = useAuth()
if(loading){
return (
<main style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
backgroundColor: '#0d1117',
color: '#e6edf3',
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"
}}>
<h2>Loading...</h2>
</main>
)
}
if(!user){
return <Navigate to={'/login'} />
}
return children
}
export default Protected