import * as React from "react";
import { get } from "lodash";

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,
  Button,
  Grid,
  GridItem,
  Countdown,
  Image,
} 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")
            maxWidth: 1200,
          }}
        >
          <Grid>
            <GridItem xs>
              <Image
                src={theme.logoDark}
                style={{ maxWidth: 250, marginTop: 40 }}
              />
            </GridItem>
            <GridItem xs={5}>
              <Container style={{ textAlign: "center" }}>
                <Text style={{ ...style.TEXT, color: theme.highlightColor }}>
                  Registration Closes In...
                </Text>

                <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>
            </GridItem>
            <GridItem xs>
              <Text style={{ ...style.TEXT, marginTop: 10, float: "right" }}>
                <p>
                  Need Help? <br />
                  Call Us at 1-888-555-1212
                  <br />
                  ...or <a href="#">email support</a>
                </p>
              </Text>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
