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

export function RequireToken({ children }) {

  let token = useSelector((state) => state.token.token)
  let location = useLocation();

  if (!token) {
    console.log('falta authorizacion user')
    return <Navigate to="/logincd" state={{ from: location }} replace />;
  }

  return children;
}
