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";

import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";

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.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",
                  },
                ]}
              />
              <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}>
              <ImagePlaceholder
                type={ImagePlaceholderTypes.NONE}
                style={{ backgroundColor: theme.backgroundColor, height: 200 }}
              />

              <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}
              />
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
