import React from "react";
import MachinesContainer from "../../machines/components/MachinesContainer";
import NetworkStateProvider from "../state/NetworkStateProvider";
import { usePermissions } from "../../../hooks";
import NotAllowed from "../../../components/common/NotAllowed";

const NetworkContainer = (): React.ReactElement | null => {
  const { loading, viewMachines } = usePermissions();

  if (loading) return null;
  if (!viewMachines) return <NotAllowed />;

  return (
    <NetworkStateProvider>
      <MachinesContainer />
    </NetworkStateProvider>
  );
};

export default NetworkContainer;
