import * as React from "react";
import { get } from "lodash";
import {
  faFacebookF,
  faGoogle,
  faTwitter,
  faInstagram,
} from "@fortawesome/free-brands-svg-icons";

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,
  Grid,
  GridItem,
  FormField,
  Button,
  Navigation,
} from "@sc/plugins/webcomponents/v2";
import {
  NavigationLayouts,
  ItemTypes,
} from "@sc/plugins/webcomponents/v2/Navigation/types";

import { IconSource } from "@sc/plugins/webcomponents/v2/Icon/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>
              <Headline style={{ ...style.HEADLINE, padding: 20 }}>
                Subscribe to stay tuned for news and latest updates.
              </Headline>
            </GridItem>
            <GridItem xs={5}>
              <Container style={{}}>
                <Grid spacing={4} style={{ padding: 20 }}>
                  <GridItem xs={8}>
                    {doIShow(content, "input") && (
                      <FormField
                        type="Text"
                        name="email"
                        placeholder="Enter Your Email"
                        style={style.FORM_FIELD.style}
                        inputStyle={style.FORM_FIELD.inputStyle}
                      />
                    )}
                  </GridItem>
                  <GridItem xs={4}>
                    {doIShow(content, "cta_button") && (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Get Started"
                        caption1style={style.BUTTON.caption1}
                      />
                    )}
                  </GridItem>
                </Grid>
              </Container>
            </GridItem>
            <GridItem xs>
              <Navigation
                layout={NavigationLayouts.SIX}
                style={{ padding: 35 }}
                linkStyle={style.NAVIGATION.linkStyle}
                items={[
                  {
                    type: ItemTypes.LISTITEM,
                    icon: faTwitter,
                    iconSource: IconSource.FONTAWESOME,
                    href: "./#",
                  },
                  {
                    type: ItemTypes.LISTITEM,
                    icon: faFacebookF,
                    iconSource: IconSource.FONTAWESOME,
                    href: "./#",
                  },
                  {
                    type: ItemTypes.LISTITEM,
                    icon: faGoogle,
                    iconSource: IconSource.FONTAWESOME,
                    href: "./#",
                  },
                  {
                    type: ItemTypes.LISTITEM,
                    icon: faInstagram,
                    iconSource: IconSource.FONTAWESOME,
                    href: "./#",
                  },
                ]}
              />
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
