Felix Zieger
update
018dc4e
raw
history blame contribute delete
502 Bytes
import { ReactNode } from "react";
import { Navigate } from "react-router-dom";
import { useAuth } from "@/contexts/AuthContext";
interface ProtectedRouteProps {
children: ReactNode;
}
export const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
const { user, loading } = useAuth();
if (loading) {
return <div className="flex h-screen items-center justify-center">Loading...</div>;
}
if (!user) {
return <Navigate to="/auth/login" />;
}
return <>{children}</>;
};