mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-05 13:10:08 +00:00
✨ login page
This commit is contained in:
16
src/routes/protect.tsx
Normal file
16
src/routes/protect.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
|
||||
export const ProtectedRoute = ({ children }: {
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
const { profile } = useAuth();
|
||||
|
||||
if (!profile && window.location.pathname !== "/dashboard/login") {
|
||||
return <Navigate to="/dashboard/login" />;
|
||||
}
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
export default ProtectedRoute;
|
||||
Reference in New Issue
Block a user