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 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"),
          }}
        >
          <Grid spacing={5}>
            <GridItem xs={7}>
              <Headline style={style.HEADLINE}>
                You're Almost Finished...
              </Headline>
              <Headline style={{ ...style.SUBHEADLINE, marginTop: 30 }}>
                Billing Information
              </Headline>

              <Text style={{ ...style.TEXT, marginTop: 10 }}>
                You're information is secure and will not be shared with a 3rd
                party
              </Text>
              <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",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "lastName",
                    placeholder: "Last Name",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "email",
                    placeholder: "Email",
                  },
                ]}
              />
              <Headline style={{ ...style.SUBHEADLINE, marginTop: 30 }}>
                Billing Address
              </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: "Street Address",
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "lastName",
                    placeholder: "City",
                  },
                  {
                    type: FormFieldTypes.SELECT,
                    name: "email",
                    placeholder: "State",
                    options: state,
                    inputStyle: {
                      ...style.FORM_FIELD.inputStyle,
                      paddingLeft: 7,
                      paddingRight: 7,
                    },
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "email",
                    placeholder: "Zip/Postal Code",
                  },
                  {
                    type: FormFieldTypes.SELECT,
                    name: "email",
                    placeholder: "Country",
                    options: country,
                    inputStyle: {
                      ...style.FORM_FIELD.inputStyle,
                      paddingLeft: 7,
                      paddingRight: 7,
                    },
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "email",
                    placeholder: "Phone",
                  },
                  {
                    type: FormFieldTypes.CHECKBOX,
                    name: "email",
                    label: "Shipping same as Billing",
                  },
                ]}
              />
              <Headline style={style.SUBHEADLINE}>Order Summary</Headline>
              <OrderSummary
                cart={[
                  {
                    title: "10 Minute Funnels Premium Subscription",
                    value: "FREE",
                  },
                  { title: "Shipping", value: 7.95 },
                ]}
                showHeader
                // showSubtotal
                showTotal
                style={{ marginTop: 40 }}
                type={OrderSummaryTypes.STANDARD}
              />
              <Container
                style={{
                  border: `1px solid #DDD`,
                  backgroundColor: "#EEE",
                  padding: 30,
                  borderRadius: 3,
                  marginTop: 40,
                }}
              >
                <Headline style={style.SUBHEADLINE}>
                  Security is our top priority
                </Headline>
                <Text style={{ ...style.TEXT, marginTop: 20 }}>
                  {lorem.generateParagraphs(1)}
                </Text>
              </Container>
              <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",
                  },
                  {
                    type: FormFieldTypes.SELECT,
                    name: "lastName",
                    placeholder: "Month",
                    options: expirationMonth,
                    inputStyle: {
                      ...style.FORM_FIELD.inputStyle,
                      paddingLeft: 7,
                      paddingRight: 7,
                    },
                    xs: 4,
                  },
                  {
                    type: FormFieldTypes.SELECT,
                    name: "email",
                    placeholder: "Year",
                    options: expirationYear,
                    inputStyle: {
                      ...style.FORM_FIELD.inputStyle,
                      paddingLeft: 7,
                      paddingRight: 7,
                    },
                    xs: 4,
                  },
                  {
                    type: FormFieldTypes.TEXT,
                    name: "email",
                    placeholder: "CVC",
                    xs: 4,
                  },
                  {
                    type: FormFieldTypes.CHECKBOX,
                    name: "email",
                    label: "I agree to the terms and conditions",
                  },
                ]}
              />
              <Button
                style={{ ...style.BUTTON.style, marginTop: 30 }}
                caption1="Get Instant Access"
                caption1style={style.BUTTON.caption1}
              />
            </GridItem>
            <GridItem xs={5}>
              <Container
                style={{
                  borderRadius: 5,
                  backgroundColor: theme.backgroundColor,
                  padding: 30,
                }}
              >
                <Headline
                  style={{ ...style.SUBHEADLINE, color: theme.foregroundColor }}
                >
                  Your Purchase Includes These BONUSES
                </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,
                    },
                    {
                      caption:
                        "<strong>Bonus #4:</strong> " +
                        startCase(lorem.generateWords(3)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                  ]}
                />

                <Headline
                  style={{ ...style.SUBHEADLINE, color: theme.foregroundColor }}
                >
                  Use these bonuses to help you:
                </Headline>

                <List
                  data={[
                    {
                      caption:
                        `<strong>${startCase(
                          lorem.generateWords(3)
                        )}:</strong> ` + startCase(lorem.generateSentences(1)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                    {
                      caption:
                        `<strong>${startCase(
                          lorem.generateWords(3)
                        )}:</strong> ` + startCase(lorem.generateSentences(1)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                    {
                      caption:
                        `<strong>${startCase(
                          lorem.generateWords(3)
                        )}:</strong> ` + startCase(lorem.generateSentences(1)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                    {
                      caption:
                        `<strong>${startCase(
                          lorem.generateWords(3)
                        )}:</strong> ` + startCase(lorem.generateSentences(1)),
                      style: style.LISTITEM.style,
                      iconStyle: style.LISTITEM.iconStyle,
                      contentStyle: style.LISTITEM.contentStyle,
                      icon: IconTypes.CheckCircleOutline,
                    },
                  ]}
                />

                <Headline
                  style={{
                    ...style.HEADLINE,
                    marginTop: 30,
                    color: theme.foregroundColor,
                  }}
                >
                  Need Help?
                </Headline>

                <Text style={{ ...style.TEXT, color: theme.foregroundColor }}>
                  Call us at 1-888-555-1212
                  <br />
                  Mon - Fri 9:00 - 5:00 EST
                </Text>

                <Headline
                  style={{
                    ...style.HEADLINE,
                    marginTop: 30,
                    color: theme.foregroundColor,
                  }}
                >
                  Customer Support:
                </Headline>
                <Text style={{ ...style.TEXT, color: theme.foregroundColor }}>
                  contact@email.com
                </Text>
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
