import * as React from "react";
import { get } from "lodash";

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,
  List,
  ListItem,
} from "@sc/plugins/webcomponents/v2";
import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";
import { Icon, IconTypes } from "@sc/plugins/webcomponents/v2/Icon";

const LIGroup = ({ data }) => {
  const { title, text } = data;

  return (
    <ListItem
      icon={IconTypes.AccountCircle}
      iconStyle={style.LI.iconStyle}
      style={style.LI.style}
    >
      <Text
        style={{
          ...style.HEADLINE,
          padding: 0,
        }}
      >
        {title}
      </Text>
      <Text
        style={{
          ...style.TEXT,
          padding: 0,
        }}
      >
        {text}
      </Text>
    </ListItem>
  );
};

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);

  const liData = {
    title: "Proven Strategy",
    text:
      "It's true.  Getting results is much easier than you think.  The truth",
  };

  return (
    <Block>
      <Section style={style.SECTION}>
        <Container
          style={{
            ...style.SECTION_INNER,
            maxWidth: get(data, "section.pageMargin"),
          }}
        >
          <Container style={{ maxWidth: 900, margin: "0 auto" }}>
            <Grid spacing={10}>
              <GridItem xs={6}>
                <List style={style.LIST}>
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                </List>
              </GridItem>
              <GridItem xs={6}>
                <List style={style.LIST}>
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                  <LIGroup data={liData} />
                </List>
              </GridItem>
            </Grid>
          </Container>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
