text: import React from 'react';
  import { Route, Redirect } from 'react-router-dom';
  import { useSelector } from 'react-redux';
  
  const PrivateRoute = ({ component: Component, ...rest }) => {
    const { isAuthenticated, loading } = useSelector((state) => state.users);
  
    return (
      <Route
        {...rest}
        render={(props) =>
          !isAuthenticated && !loading ? (
            <Redirect
              to={{ pathname: '/login', state: { from: props.location } }}
            />
          ) : (
            <Component />
          )
        }
      />
    );
  };
  
  export default PrivateRoute;
  