"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 Tabs_1 = require("../../../../components/Tabs");
const FormLayout_1 = tslib_1.__importStar(require("../../../../components/FormLayout"));
const Input_1 = tslib_1.__importDefault(require("../../../../components/Input"));
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 Flex_1 = require("../../../../components/Flex");
const ScheduleSettingsIPushPull = (props) => {
    const handleNameChange = (event) => {
        props.onChange({
            ...props.iPushPull,
            Name: event.target.value,
        });
    };
    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(Flex_1.Box, { "data-name": "schedule-settings-ipushpull" },
        React.createElement(Tabs_1.Tabs, { autoFocus: false },
            React.createElement(Tabs_1.Tabs.Tab, null, "Settings"),
            React.createElement(Tabs_1.Tabs.Content, null,
                React.createElement(FormLayout_1.default, null,
                    React.createElement(FormLayout_1.FormRow, { label: "Name" },
                        React.createElement(Input_1.default, { "data-name": "schedule-name", className: "twa:w-[300px]", onChange: handleNameChange, placeholder: "Enter Schedule Name", type: "string", value: props.iPushPull?.Name ?? '' })),
                    React.createElement(FormLayout_1.FormRow, { label: "" },
                        React.createElement(Flex_1.Box, { className: "twa:h-2" })),
                    React.createElement(FormLayout_1.FormRow, { label: "Select Report" },
                        React.createElement(DropdownButton_1.default, { "data-name": "report-name", disabled: props.allReports.length == 0, items: reportOptions, className: "twa:w-[300px]" }, 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, className: "twa:w-[300px]" }, 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, className: "twa:w-[300px]" }, props?.iPushPull?.IPushPullReport?.Page || 'Select Page')),
                    React.createElement(FormLayout_1.FormRow, { label: "Data Type" },
                        React.createElement(Radio_1.default, { "data-name": "data-type", className: "twa: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;
