import Zone from "@insite/client-framework/Components/Zone";
import WidgetModule from "@insite/client-framework/Types/WidgetModule";
import WidgetProps from "@insite/client-framework/Types/WidgetProps";
import GridContainer, { GridContainerProps } from "@insite/mobius/GridContainer";
import GridItem, { GridItemProps } from "@insite/mobius/GridItem";
import getColor from "@insite/mobius/utilities/getColor";
import React from "react";
import { css } from "styled-components";

type Props = WidgetProps;

export interface OnePageCheckoutConfirmationPageContainerStyles {
    container?: GridContainerProps;
    topGridItem?: GridItemProps;
    leftGridItem?: GridItemProps;
    spaceGridItem?: GridItemProps;
    rightGridItem?: GridItemProps;
    bottomGridItem?: GridItemProps;
}

export const containerStyles: OnePageCheckoutConfirmationPageContainerStyles = {
    topGridItem: { width: 12 },
    leftGridItem: {
        width: [12, 12, 6, 7, 7],
        css: css`
            & > div > div:not(:last-child) {
                padding-bottom: 30px;
                border-bottom: 1px solid ${getColor("common.border")};
            }
        `,
    },
    spaceGridItem: { width: [0, 0, 1, 1, 1] },
    rightGridItem: { width: [12, 12, 5, 4, 4] },
    bottomGridItem: {
        width: 12,
        css: css`
            & > div > div:first-child {
                padding-top: 30px;
                border-top: 1px solid ${getColor("common.border")};
            }
        `,
    },
};

const styles = containerStyles;

const OnePageCheckoutConfirmationPageContainer = ({ id }: Props) => {
    return (
        <GridContainer {...styles.container}>
            <GridItem {...styles.topGridItem}>
                <Zone zoneName="Content0" contentId={id} />
            </GridItem>
            <GridItem {...styles.leftGridItem}>
                <Zone zoneName="Content1" contentId={id} />
            </GridItem>
            <GridItem {...styles.spaceGridItem}></GridItem>
            <GridItem {...styles.rightGridItem}>
                <Zone zoneName="Content2" contentId={id} />
            </GridItem>
            <GridItem {...styles.bottomGridItem}>
                <Zone zoneName="Content3" contentId={id} />
            </GridItem>
        </GridContainer>
    );
};

const widgetModule: WidgetModule = {
    component: OnePageCheckoutConfirmationPageContainer,
    definition: {
        displayName: "Page Container",
        group: "One Page Checkout Confirmation",
        allowedContexts: ["OnePageCheckoutConfirmationPage"],
    },
};

export default widgetModule;
