import { useAuth } from '../contexts/AuthContext';

const RoleGuard = ({ allowedRoles, children }) => {
  const { isInRoles } = useAuth();

  // If at least one of the user's role is in the allowed list, show the content
  if (isInRoles(allowedRoles)) {
    return <>{children}</>;
  }

  // Otherwise, hide the content
  return null;
};

export default RoleGuard;