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 { CountDownTypes } from "@sc/plugins/webcomponents/v2/Countdown/types";

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

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

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={0}
            style={{
              maxWidth: 650,
              margin: "0 auto",
            }}
          >
            <GridItem>
              <Text style={style.TEXT}>82% Discount available for:</Text>
            </GridItem>
            <GridItem>
              <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={{}}
              />
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
