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,
  FormBuilder,
} from "@sc/plugins/webcomponents/v2";
import { FormFieldTypes } from "@sc/modules/v2/CRUD/FormBuilder/types";
import { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";

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")
            maxWidth: 550,
          }}
        >
          <Headline style={style.HEADLINE}>
            Create Your Free 10 Minute Funnels Account
          </Headline>
          <Text style={style.TEXT}>{lorem.generateSentences(1)}</Text>
          <FormBuilder
            style={{ marginTop: 30 }}
            data={[
              {
                type: FormFieldTypes.TEXT,
                name: "firstname",
                placeholder: "Enter your first name here",
                style: style.FORM_FIELD.style,
                inputStyle: style.FORM_FIELD.inputStyle,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "lastname",
                placeholder: "Enter your last name here",
                style: style.FORM_FIELD.style,
                inputStyle: style.FORM_FIELD.inputStyle,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "email",
                placeholder: "Enter your email address here",
                style: style.FORM_FIELD.style,
                inputStyle: style.FORM_FIELD.inputStyle,
              },
            ]}
          />

          <Button
            style={{ ...style.BUTTON.style, marginLeft: 10 }}
            caption1="Get Instant Access"
            caption1style={style.BUTTON.caption1}
          />
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
