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,
  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"),
          }}
        >
          <Grid>
            <GridItem xs={8}>
              <Container
                style={{
                  background: theme.backgroundColor,
                  padding: "250px 350px 250px 150px",
                }}
              >
                <Headline style={style.HEADLINE}>
                  Don't waste your time join us
                </Headline>
                <Text style={style.TEXT}>
                  The goal is to facilitate usability and efficiency as much as
                  possible. Common elements found in interface design
                </Text>
              </Container>
            </GridItem>
            <GridItem
              xs={4}
              style={{
                display: "flex",
                alignItems: "center",
                background: "#f0f0f0",
              }}
            >
              <Container
                style={{
                  padding: 30,
                  borderRadius: 5,
                  marginLeft: -250,
                  maxWidth: 400,
                  backgroundColor: theme.foregroundColor,
                }}
              >
                <Headline
                  style={{
                    ...style.HEADLINE,
                    color: "black",
                    textAlign: "center",
                    fontSize: "16pt",
                    paddingBottom: 0,
                  }}
                >
                  Create new account
                </Headline>
                <Text
                  style={{
                    ...style.TEXT,
                    color: "black",
                    textAlign: "center",
                  }}
                >
                  The goal is to facilitate usability and efficieny as much as
                  possible
                </Text>
                <FormBuilder
                  data={[
                    {
                      type: FormFieldTypes.TEXT,
                      name: "company",
                      placeholder: "Name",
                      style: style.FORM_FIELD.style,
                      inputStyle: style.FORM_FIELD.inputStyle,
                      icon: IconTypes.AccountBoxRounded,
                      iconStyle: style.FORM_FIELD.iconStyle,
                    },
                    {
                      type: FormFieldTypes.TEXT,
                      name: "email",
                      placeholder: "Email",
                      style: style.FORM_FIELD.style,
                      inputStyle: style.FORM_FIELD.inputStyle,
                      icon: IconTypes.Email,
                      iconStyle: style.FORM_FIELD.iconStyle,
                    },
                    {
                      type: FormFieldTypes.PASSWORD,
                      name: "password",
                      placeholder: "Password",
                      style: style.FORM_FIELD.style,
                      inputStyle: style.FORM_FIELD.inputStyle,
                      icon: IconTypes.Lock,
                      iconStyle: style.FORM_FIELD.iconStyle,
                    },
                  ]}
                />
                <Button
                  style={{ ...style.BUTTON.style, marginTop: 40 }}
                  caption1="Sign up"
                  caption1style={style.BUTTON.caption1}
                />
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
