fix sidebar - complete auth layout

This commit is contained in:
Alihaghighattalab
2024-08-17 17:08:25 +03:30
parent ddf6bcd287
commit 86b5b41abf
5 changed files with 64 additions and 25 deletions
+19
View File
@@ -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}
</>
)
}