mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 20:50:07 +00:00
16 lines
410 B
TypeScript
16 lines
410 B
TypeScript
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" />{children}</>;
|
|
}
|
|
|
|
return children;
|
|
};
|
|
|
|
export default ProtectedRoute; |