import { useSelector } from "react-redux";
import PropTypes from "prop-types";
import Loadingredirect from "./Loadingredirect";

const PrivateRoute = ({ children }) => {
  const { user } = useSelector((state) => ({ ...state.auth }));
  return user ? children : <Loadingredirect />;
};

PrivateRoute.propTypes = {
  children: PropTypes.node.isRequired, // Validate the presence of children
};

export default PrivateRoute;


