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 { VideoPlaceholder } from "../../Placeholders";
import { getClipPath, ClipPathTypes } from "@sc/plugins/utilities/clipPaths";

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

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  FormBuilder,
  Grid,
  GridItem,
} from "@sc/plugins/webcomponents/v2";
import { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";
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"),
          }}
        >
          <Grid spacing={5}>
            <GridItem xs={7}>
              <Headline style={style.HEADLINE}>
                {startCase(lorem.generateSentences(1))}
              </Headline>
              <VideoPlaceholder style={{ color: "white", height: 50 }} />
              <Container
                style={{
                  ...style.SECTION,
                  background: theme.backgroundColor,
                  // padding: 40,
                  marginTop: 40,
                  textAlign: "center",
                  // clipPath: getClipPath({
                  //   type: ClipPathTypes.RIGHTPOINT,
                  // }),
                  clipPath: `polygon(0% 0%, 90% 0%, 100% 50%, 90% 100%, 0% 100%)`,
                }}
              >
                <Headline
                  style={{ ...style.HEADLINE, color: theme.foregroundColor }}
                >
                  {startCase(lorem.generateWords(5))}
                </Headline>
              </Container>
            </GridItem>
            <GridItem xs={5}>
              <Container
                style={{
                  border: `1px solid ${theme.backgroundColor}`,
                }}
              >
                <Container style={{ textAlign: "center" }}>
                  <Container
                    style={{
                      backgroundColor: theme.backgroundColor,
                    }}
                  >
                    <Headline
                      style={{
                        ...style.HEADLINE,
                        padding: 40,
                        fontSize: "26pt",
                        lineHeight: "32pt",
                        color: theme.foregroundColor,
                      }}
                    >
                      Replace This Headline
                    </Headline>
                  </Container>
                  <Container
                    style={{
                      display: "inline-block",
                      borderStyle: "solid",
                      borderWidth: `20px 30px 0 30px`,
                      borderColor: `${theme.backgroundColor} transparent transparent transparent`,
                    }}
                  />
                </Container>
                <Container style={{ padding: 30 }}>
                  <Headline style={style.HEADLINE}>
                    {startCase(lorem.generateWords(3))}
                  </Headline>
                  <Headline style={style.SUBHEADLINE}>
                    {lorem.generateSentences(1)}
                  </Headline>
                  <FormBuilder
                    style={{ marginTop: 10 }}
                    fieldStyle={style.FORM_FIELD.style}
                    inputStyle={style.FORM_FIELD.inputStyle}
                    labelStyle={style.FORM_FIELD.labelStyle}
                    data={[
                      {
                        type: FormFieldTypes.TEXT,
                        name: "firstName",
                        placeholder: "Name",
                      },
                      {
                        type: FormFieldTypes.TEXT,
                        name: "email",
                        placeholder: "Email Address",
                      },
                    ]}
                  />

                  <Button
                    style={{ ...style.BUTTON.style, marginTop: 30 }}
                    caption1="Yes! I Want This Product"
                    caption1style={style.BUTTON.caption1}
                    caption2="Please add this to my shopping cart"
                    caption2style={style.BUTTON.caption2}
                    icon={IconTypes.Email}
                    iconStyle={{
                      marginLeft: 10,
                      marginTop: 2,
                      fontSize: "26pt",
                    }}
                  />

                  <Text style={{ ...style.TEXT, fontSize: "9pt" }}>
                    {lorem.generateSentences(1)}
                  </Text>
                </Container>
              </Container>
            </GridItem>
          </Grid>
          <div style={{ clear: "both" }} />
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
