import * as React from "react";
import { get } from "lodash";
// import { PlayArrow } from "@material-ui/icons";

import { style } from "./style";
import { default as defaultData } from "./data.json";

import { doIShow, combineData } from "../../utils";
import theme from "../../theme";

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Grid,
  GridItem,
  Divider,
  Icon,
} from "@sc/plugins/webcomponents/v2";
import { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";

import { DividerTypes } from "@sc/plugins/webcomponents/v2/Divider/types";

type LayoutProps = {
  data: any;
};

const Layout: React.FC<LayoutProps> = ({ data }) => {
  const initialContent = {
    main_headline: {
      html: "Headline Goes Here",
    },
    sub_headline: {
      html: "Sub Headline Text Content Goes Here",
    },
  };

  const content = combineData(initialContent, defaultData, data);

  return (
    <Block>
      <Section style={style.SECTION}>
        <Container style={style.SECTION_INNER}>
          <Grid spacing={1}>
            <GridItem xs={5}>
              <Container
                style={{ paddingLeft: 55, paddingTop: 110, paddingBottom: 110 }}
              >
                <Grid>
                  <GridItem xs={2}>
                    <Icon type={IconTypes.PlayArrow} style={style.ICON} />
                  </GridItem>
                  <GridItem xs={10}>
                    {doIShow(content, "main_headline") && (
                      <Headline
                        name="Main Headline"
                        id="main_headline"
                        style={{
                          ...style.HEADLINE,
                          ...get(content, "main_headline.style", {}),
                        }}
                      >
                        {get(content, "main_headline.html", "...")}
                      </Headline>
                    )}
                    {doIShow(content, "sub_headline") && (
                      <Text
                        name="Sub Headline"
                        id="sub_headline"
                        style={{
                          ...style.TEXT,
                          ...get(content, "sub_headline.style", {}),
                        }}
                      >
                        {get(content, "sub_headline.html", "...")}
                      </Text>
                    )}
                    {doIShow(content, "cta_button") && (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Get Started"
                        caption1style={style.BUTTON.caption1}
                      />
                    )}
                  </GridItem>
                </Grid>
              </Container>
            </GridItem>
            <GridItem xs={2} style={{ display: "flex", padding: 55 }}>
              <Divider
                type={DividerTypes.VERTICAL}
                color={theme.foregroundColor}
                size={1}
              />
            </GridItem>
            <GridItem xs={5}>
              <Container
                style={{
                  paddingRight: 55,
                  paddingTop: 110,
                  paddingBottom: 110,
                }}
              >
                <Grid>
                  <GridItem xs={2}>
                    <Icon type={IconTypes.PlayArrow} style={style.ICON} />
                  </GridItem>
                  <GridItem xs={10}>
                    {doIShow(content, "main_headline") && (
                      <Headline
                        name="Main Headline"
                        id="main_headline"
                        style={{
                          ...style.HEADLINE,
                          ...get(content, "main_headline.style", {}),
                        }}
                      >
                        {get(content, "main_headline.html", "...")}
                      </Headline>
                    )}
                    {doIShow(content, "sub_headline") && (
                      <Text
                        name="Sub Headline"
                        id="sub_headline"
                        style={{
                          ...style.TEXT,
                          ...get(content, "sub_headline.style", {}),
                        }}
                      >
                        {get(content, "sub_headline.html", "...")}
                      </Text>
                    )}
                    {doIShow(content, "cta_button") && (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Get Started"
                        caption1style={style.BUTTON.caption1}
                      />
                    )}
                  </GridItem>
                </Grid>
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
