"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScheduleSettingsIPushPull = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const Tabs_1 = require("../../../../components/Tabs");
const FormLayout_1 = tslib_1.__importStar(require("../../../../components/FormLayout"));
const Radio_1 = tslib_1.__importDefault(require("../../../../components/Radio"));
const DropdownButton_1 = tslib_1.__importDefault(require("../../../../components/DropdownButton"));
const OnePageAdaptableWizard_1 = require("../../../Wizard/OnePageAdaptableWizard");
const ScheduleSettingsIPushPull = (props) => {
    const reportOptions = props.allReports.map((report) => ({
        label: report.Name,
        value: report.Name,
        onClick: () => props.onChange({
            ...props.iPushPull,
            IPushPullReport: {
                ...props.iPushPull.IPushPullReport,
                ReportName: report.Name,
            },
        }),
    }));
    const folderOptions = props.allFolders.map((folder) => ({
        label: folder.Name,
        value: folder.Name,
        onClick: () => props.onChange({
            ...props.iPushPull,
            IPushPullReport: {
                ...props.iPushPull.IPushPullReport,
                Folder: folder.Name,
            },
        }),
    }));
    const pagesOptions = props.availablePages.map((page) => ({
        label: page,
        value: page,
        onClick: () => props.onChange({
            ...props.iPushPull,
            IPushPullReport: {
                ...props.iPushPull.IPushPullReport,
                Page: page,
            },
        }),
    }));
    const handleDataTypeChange = (Transmission) => props.onChange({
        ...props.iPushPull,
        Transmission,
    });
    return (React.createElement(rebass_1.Box, { "data-name": "schedule-settings-ipushpull" },
        React.createElement(Tabs_1.Tabs, { autoFocus: false },
            React.createElement(Tabs_1.Tabs.Tab, null, "Ipushpull Schedule Settings"),
            React.createElement(Tabs_1.Tabs.Content, null,
                React.createElement(FormLayout_1.default, null,
                    React.createElement(FormLayout_1.FormRow, { label: "Select Report" },
                        React.createElement(DropdownButton_1.default, { "data-name": "report-name", disabled: props.allReports.length == 0, items: reportOptions, style: { width: 300 } }, props?.iPushPull?.IPushPullReport?.ReportName || 'Select Report')),
                    React.createElement(FormLayout_1.FormRow, { label: "Select Folder" },
                        React.createElement(DropdownButton_1.default, { "data-name": "folder-name", disabled: props.allFolders.length == 0, items: folderOptions, style: { width: 300 } }, props?.iPushPull?.IPushPullReport?.Folder || 'Select Folder')),
                    React.createElement(FormLayout_1.FormRow, { label: "Select Page" },
                        React.createElement(DropdownButton_1.default, { "data-name": "page-name", disabled: props.allFolders.length == 0, items: pagesOptions, style: { width: 300 } }, props?.iPushPull?.IPushPullReport?.Page || 'Select Page')),
                    React.createElement(FormLayout_1.FormRow, { label: "Data Type" },
                        React.createElement(Radio_1.default, { "data-name": "data-type", mr: 3, value: "Snapshot", checked: props.iPushPull.Transmission === 'Snapshot', onChange: (checked) => checked && handleDataTypeChange('Snapshot') }, "Snapshot (one off report)"),
                        React.createElement(Radio_1.default, { "data-name": "data-live", value: "Live Data", checked: props.iPushPull.Transmission === 'Live Data', onChange: (checked) => checked && handleDataTypeChange('Live Data') }, "Live Data (real-time updates)")),
                    React.createElement(FormLayout_1.FormRow, { label: "" },
                        React.createElement(OnePageAdaptableWizard_1.FormDescriptionText, null, "Choose whether to send ipushpull Data as 'Snapshot' (One-off report) or 'Live Data' (updating as Grid updates)")))))));
};
exports.ScheduleSettingsIPushPull = ScheduleSettingsIPushPull;
