fix sidebar - complete auth layout
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { PropsWithChildren, useEffect } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
export const Guard = ({ children }: PropsWithChildren) => {
|
||||
const navigate = useNavigate()
|
||||
const token = window.localStorage.getItem("token")
|
||||
|
||||
useEffect(() => {
|
||||
if (!token || token?.length <= 0 || token === undefined || token === null) {
|
||||
navigate("/auth/login")
|
||||
}
|
||||
}, [token , navigate])
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user