import { Navigate, useLocation } from 'react-router-dom';
import useAuth from '../Auth/useAuth';

export default function RequireAuth({ children }) {
    let auth = useAuth();
    let location = useLocation();
    if (!auth.isLogged()) {
        return <Navigate to="/login" state={{ from: location }} replace />;
    }
    return children;
}

