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,
  Grid,
  GridItem,
  FormBuilder,
  OrderSummary,
  List,
} from "@sc/plugins/webcomponents/v2";

import {
  country,
  state,
  cardType,
  expirationMonth,
  expirationYear,
} from "@sc/plugins/webcomponents/v2/FormField/selectOptions.json";
import { FormFieldTypes } from "@sc/modules/v2/CRUD/FormBuilder/types";
import { OrderSummaryTypes } from "@sc/plugins/webcomponents/v2/OrderSummary/types";
import Icon, { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";
import {
  faCcVisa,
  faCcMastercard,
  faCcAmex,
  faCcDiscover,
} from "@fortawesome/free-brands-svg-icons";
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"),
          }}
        >
          <Headline style={{ ...style.SUBHEADLINE, marginTop: 30 }}>
            Contact Information
          </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: "First Name",
                xs: 6,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "lastName",
                placeholder: "Last Name",
                xs: 6,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "email",
                placeholder: "Email Address",
                xs: 6,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "email",
                placeholder: "Phone Number",
                xs: 6,
              },
            ]}
          />

          <Grid>
            <GridItem xs={6}>
              <Headline style={{ ...style.SUBHEADLINE, marginTop: 30 }}>
                Payment Information
              </Headline>
            </GridItem>
            <GridItem xs={6}>
              <List
                style={{ float: "right", marginTop: 30 }}
                data={[
                  {
                    icon: faCcVisa,
                    iconSource: IconSource.FONTAWESOME,
                    iconStyle: {
                      fontSize: "20pt",
                      color: theme.backgroundColor,
                    },
                    style: { display: "inline-block", padding: "0 3px" },
                  },
                  {
                    icon: faCcMastercard,
                    iconSource: IconSource.FONTAWESOME,
                    iconStyle: {
                      fontSize: "20pt",
                      color: theme.backgroundColor,
                    },
                    style: { display: "inline-block", padding: "0 3px" },
                  },
                  {
                    icon: faCcDiscover,
                    iconSource: IconSource.FONTAWESOME,
                    iconStyle: {
                      fontSize: "20pt",
                      color: theme.backgroundColor,
                    },
                    style: { display: "inline-block", padding: "0 3px" },
                  },
                  {
                    icon: faCcAmex,
                    iconSource: IconSource.FONTAWESOME,
                    iconStyle: {
                      fontSize: "20pt",
                      color: theme.backgroundColor,
                    },
                    style: { display: "inline-block", padding: "0 3px" },
                  },
                ]}
              />
            </GridItem>
          </Grid>

          <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: "Credit Card Number",
                xs: 6,
              },
              {
                type: FormFieldTypes.TEXT,
                name: "email",
                placeholder: "CVC",
                xs: 6,
              },
              {
                type: FormFieldTypes.SELECT,
                name: "lastName",
                placeholder: "Month",
                options: expirationMonth,
                inputStyle: {
                  ...style.FORM_FIELD.inputStyle,
                  paddingLeft: 7,
                  paddingRight: 7,
                },
                xs: 6,
              },
              {
                type: FormFieldTypes.SELECT,
                name: "email",
                placeholder: "Year",
                options: expirationYear,
                inputStyle: {
                  ...style.FORM_FIELD.inputStyle,
                  paddingLeft: 7,
                  paddingRight: 7,
                },
                xs: 6,
              },
            ]}
          />
          <Headline style={{ ...style.SUBHEADLINE, marginTop: 40 }}>
            Order Summary
          </Headline>
          <OrderSummary
            style={{ backgroundColor: "#EEE", marginTop: 10 }}
            cart={[
              { title: "10 Minute Funnels Premium Subscription", value: 997 },
              { title: "10 Minute Funnels Premium Subscription", value: 1997 },
            ]}
            showHeader={false}
            showCart={false}
            showSubtotal={false}
            showTotal={true}
            type={OrderSummaryTypes.STANDARD}
          />

          <Button
            style={{ ...style.BUTTON.style, marginTop: 30 }}
            caption1="Place Order Now"
            caption1style={style.BUTTON.caption1}
          />
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
