import { Navigate, useLocation } from 'react-router-dom' import { useAuth } from '../contexts/AuthContext.jsx' // Gate for /admin/* — redirects to the login screen when not authenticated. export default function RequireAuth({ children }) { const { user, loading } = useAuth() const location = useLocation() if (loading) { return (
) } if (!user) { return } return children }