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

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

import { doIShow, combineData, lorem } from "../../utils";
import Icon, { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";
import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";

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

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Grid,
  GridItem,
  FormBuilder,
  List,
} from "@sc/plugins/webcomponents/v2";
import { FormFieldTypes } from "@sc/modules/v2/CRUD/FormBuilder/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,
            maxWidth: get(data, "section.pageMargin"),
          }}
        >
          <Headline style={style.HEADLINE}>
            Create Your Free 10 Minute Funnels Account
          </Headline>
          <Text style={style.TEXT}>{lorem.generateSentences(2)}</Text>

          <Grid spacing={5} style={{ marginTop: 10 }}>
            <GridItem xs={6}>
              <Headline style={style.HEADLINE}>
                Activate Your Free Account
              </Headline>
              <FormBuilder
                inputStyle={style.FORM_FIELD.inputStyle}
                labelStyle={style.FORM_FIELD.labelStyle}
                style={style.FORM_FIELD.style}
                data={[
                  {
                    type: FormFieldTypes.TEXT,
                    placeholder: "First Name",
                    name: "name",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    placeholder: "Last Name",
                    name: "last",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    placeholder: "Email",
                    name: "email",
                  },
                  {
                    type: FormFieldTypes.CHECKBOX,
                    name: "terms",
                    label: "I accept the terms",
                  },
                ]}
              />
              <Button
                style={style.BUTTON.style}
                caption1="Next"
                caption1style={style.BUTTON.caption1}
              />
            </GridItem>
            <GridItem xs={6}>
              <Container
                style={{
                  borderRadius: 5,
                  backgroundColor: theme.backgroundColor,
                  padding: 30,
                }}
              >
                <Headline
                  style={{ ...style.SUBHEADLINE, color: theme.foregroundColor }}
                >
                  What You Will Receive...
                </Headline>

                <List
                  data={[
                    {
                      caption:
                        "<strong>Bonus #1:</strong> " +
                        startCase(lorem.generateWords(3)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                    {
                      caption:
                        "<strong>Bonus #2:</strong> " +
                        startCase(lorem.generateWords(3)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                    {
                      caption:
                        "<strong>Bonus #3:</strong> " +
                        startCase(lorem.generateWords(3)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                  ]}
                />
                <ImagePlaceholder
                  type={ImagePlaceholderTypes.NONE}
                  style={{
                    backgroundColor: theme.foregroundColor,
                    height: 150,
                  }}
                />
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
