init commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Navigate, Outlet, useLocation } from "react-router"
|
||||
import { useAppSelector } from "@/store"
|
||||
|
||||
export const ProtectedRoute = () => {
|
||||
const isAuthenticated = useAppSelector((state) => state.auth.isAuthenticated)
|
||||
const location = useLocation()
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Navigate to="" state={{ from: location }} replace />
|
||||
}
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
Reference in New Issue
Block a user