import EditorObject from "@sc/modules/page/Builder/EditorObject";
import React from "react";
import BodyContent from "./component";

const CURSOR_ID = 1111;

const BodyEdit = props => {
  const childContent = props.pageContent.filter(
    itm => itm.parent === props.settings.id
  );
  let isEmpty = false;
  if (childContent.length) {
    isEmpty = !!(childContent.length === 1 && childContent[0].id === CURSOR_ID);
  } else isEmpty = true;

  const defaultBodyStyle = isEmpty ? { padding: 40 } : {};

  return (
    <EditorObject
      {...props}
      PropertiesView={Properties}
      color="transparent"
      style={{
        height: "100%",
        ...props.settings
          .properties /*marginBottom: -99999, paddingBottom: 99999*/
      }}
    >
      <BodyContent {...props} style={defaultBodyStyle} />
    </EditorObject>
  );
};

const Properties = () => <React.Fragment />;

const Body = props => (
  <div style={{ height: "100%" }}>
    <BodyEdit {...props} />
  </div>
);

export default Body;