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 { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";

import theme from "../../theme";

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Countdown,
} from "@sc/plugins/webcomponents/v2";

import { CountDownTypes } from "@sc/plugins/webcomponents/v2/Countdown/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.HEADLINE}>
            Wait! Your Order Is Not Yet Complete!{" "}
            {startCase(lorem.generateWords(4))}...FREE!
          </Headline>
          <Headline
            style={{ ...style.SUBHEADLINE, color: theme.highlightColor }}
          >
            Time Left to Complete Your Checkout
          </Headline>
          <Container style={{ padding: 50, textAlign: "center" }}>
            <Countdown
              countType={CountDownTypes.EVENT}
              eventDate={Date.now() + 2 * 24 * 60 * 60 * 1000}
              style={style.COUNTDOWN.style}
              dimensionStyle={style.COUNTDOWN.dimensionStyle}
              labelStyle={style.COUNTDOWN.labelStyle}
              numberStyle={style.COUNTDOWN.numberStyle}
              dividerStyle={style.COUNTDOWN.dividerStyle}
              showDivider={false}
              actions={{}}
            />
          </Container>
          <ImagePlaceholder
            type={ImagePlaceholderTypes.NONE}
            style={{
              backgroundColor: theme.backgroundColor,
              width: 300,
              height: 225,
              margin: "0 auto",
            }}
          />
          <Button
            style={style.BUTTON.style}
            caption1="Click Here to Close this Window"
            caption1style={style.BUTTON.caption1}
            caption2="...and complete your order!"
            caption2style={style.BUTTON.caption2}
          />
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
