import React from "react";
import { hasRole } from "../../../utils/roles";

export const RoleWrap = (props) => {
  const { groups, rolesPerProvider, providers } = props;

  const eitherComponent = props["eitherComponent"] || null;

  if (!hasRole(groups, rolesPerProvider, providers)) {
    return eitherComponent != null ? eitherComponent : <></>;
  }

  return (
    <React.Fragment>
      {props.children}
    </React.Fragment>
  )
}

