/* eslint-disable spire/export-styles */
import PageProps from "@insite/client-framework/Types/PageProps";
import WidgetModule from "@insite/client-framework/Types/WidgetModule";
import WidgetProps from "@insite/client-framework/Types/WidgetProps";
import Typography from "@insite/mobius/Typography";
import React, { FC } from "react";

const defaultJavascript = "";

const enum fields {
    contentField = "contentField",
}

interface Props extends PageProps, WidgetProps {
    contentField: {
        [fields.contentField]: string;
    };
}

const ServiceWorkerJsContent: FC<Props> = props => {
    return <Typography style={{ whiteSpace: "pre-wrap" }}>{props.fields[fields.contentField]}</Typography>;
};

const widgetModule: WidgetModule = {
    component: ServiceWorkerJsContent,
    definition: {
        group: "Service Worker JS",
        displayName: "Content",
        allowedContexts: ["ServiceWorkerJsPage"],
        fieldDefinitions: [
            {
                name: "contentField",
                displayName: "Content",
                editorTemplate: "CodeField",
                defaultValue: defaultJavascript,
                fieldType: "General",
                isRequired: true,
                options: {
                    mode: "javascript",
                },
            },
        ],
    },
};

export default widgetModule;
