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

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

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

import theme from "../../theme";

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Grid,
  GridItem,
  FormBuilder,
} from "@sc/plugins/webcomponents/v2";
import { FormFieldTypes } from "@sc/modules/v2/CRUD/FormBuilder/types";
import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";

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,
            maxWidth: get(data, "section.pageMargin"),
          }}
        >
          <Grid spacing={10}>
            <GridItem xs={6}>
              <ImagePlaceholder
                type={ImagePlaceholderTypes.NONE}
                style={{ backgroundColor: theme.backgroundColor }}
              />
            </GridItem>
            <GridItem xs={6}>
              <Headline style={style.HEADLINE}>
                Step 1: Where should I send your free book &amp; gifts?
              </Headline>
              <Text style={style.TEXT}>{lorem.generateSentences(1)}</Text>
              <FormBuilder
                inputStyle={style.FORM_FIELD.inputStyle}
                style={style.FORM_FIELD.style}
                data={[
                  {
                    type: FormFieldTypes.TEXT,
                    placeholder: "Name",
                    name: "name",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    placeholder: "Email",
                    name: "email",
                  },
                ]}
              />
              <Button
                style={style.BUTTON.style}
                caption1="Continue..."
                caption1style={style.BUTTON.caption1}
              />
              <Text style={style.TEXT}>{lorem.generateSentences(2)}</Text>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
