import React from "react";
import PropTypes from "prop-types";
import ArticleRow from "./article-body-row";

const ArticleBody = props => {
  const { section, content: bodyContent, contextUrl } = props;
  const contentArray = bodyContent.map((data, index) => {
    const item = {
      data,
      index
    };
    if (data.name === "ad") {
      item.data.attributes = {
        ...item.data.attributes,
        ...{ section, contextUrl }
      };
    }
    return item;
  });
  const BodyView = contentArray.map(content => (
    <ArticleRow key={`cont-${content.index}`} content={content} />
  ));

  return BodyView;
};

ArticleBody.propTypes = {
  content: PropTypes.arrayOf(
    PropTypes.shape({
      attributes: PropTypes.object,
      children: PropTypes.arrayOf(PropTypes.object),
      name: PropTypes.string
    })
  ).isRequired,
  section: PropTypes.string,
  contextUrl: PropTypes.string.isRequired
};

export default ArticleBody;

@@ -236,17 +236,20 @@
 nt.map((
-d
+rowD
 ata, ind
@@ -286,16 +286,44 @@
     data
+: Object.assign(%7B%7D, rowData)
 ,%0A      
@@ -343,17 +343,20 @@
     if (
-d
+rowD
 ata.name

use mutable object as apollo uses immutables (#766)