"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) => {
    var _a, _b, _c, _d, _e, _f;
    const reportOptions = props.allReports.map((report) => ({
        label: report.Name,
        value: report.Name,
        onClick: () => props.onChange(Object.assign(Object.assign({}, props.iPushPull), { IPushPullReport: Object.assign(Object.assign({}, props.iPushPull.IPushPullReport), { ReportName: report.Name }) })),
    }));
    const folderOptions = props.allFolders.map((folder) => ({
        label: folder.Name,
        value: folder.Name,
        onClick: () => props.onChange(Object.assign(Object.assign({}, props.iPushPull), { IPushPullReport: Object.assign(Object.assign({}, props.iPushPull.IPushPullReport), { Folder: folder.Name }) })),
    }));
    const pagesOptions = props.availablePages.map((page) => ({
        label: page,
        value: page,
        onClick: () => props.onChange(Object.assign(Object.assign({}, props.iPushPull), { IPushPullReport: Object.assign(Object.assign({}, props.iPushPull.IPushPullReport), { Page: page }) })),
    }));
    const handleDataTypeChange = (Transmission) => props.onChange(Object.assign(Object.assign({}, 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 } }, ((_b = (_a = props === null || props === void 0 ? void 0 : props.iPushPull) === null || _a === void 0 ? void 0 : _a.IPushPullReport) === null || _b === void 0 ? void 0 : _b.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 } }, ((_d = (_c = props === null || props === void 0 ? void 0 : props.iPushPull) === null || _c === void 0 ? void 0 : _c.IPushPullReport) === null || _d === void 0 ? void 0 : _d.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 } }, ((_f = (_e = props === null || props === void 0 ? void 0 : props.iPushPull) === null || _e === void 0 ? void 0 : _e.IPushPullReport) === null || _f === void 0 ? void 0 : _f.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;
