"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataImportPopup = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const HelpBlock_1 = tslib_1.__importDefault(require("../../components/HelpBlock"));
const SimpleButton_1 = tslib_1.__importDefault(require("../../components/SimpleButton"));
const PopupPanel_1 = require("../Components/Popups/AdaptablePopup/PopupPanel");
const DataImportWizard_1 = require("./DataImportWizard");
const Flex_1 = require("../../components/Flex");
const DataImportPopup = (props) => {
    const [isWizardOpen, setIsWizardOpen] = React.useState(false);
    React.useEffect(() => {
        if (props?.popupParams == undefined ||
            (props.popupParams?.action === 'New' && props.popupParams?.source !== 'ModuleMenu')) {
            setIsWizardOpen(true);
        }
    }, []);
    return (React.createElement(React.Fragment, null,
        React.createElement(PopupPanel_1.PopupPanel, { headerText: 'Data Import', glyphicon: 'import', infoLink: props.moduleInfo.HelpPage },
            React.createElement(Flex_1.Box, null,
                React.createElement(HelpBlock_1.default, { className: "twa:mb-2 twa:text-3" }, "Click the 'Import Data' button to Insert or Update data into AdapTable"),
                React.createElement(SimpleButton_1.default, { icon: "import", variant: "raised", onClick: () => setIsWizardOpen(true) }, "Import Data"))),
        isWizardOpen && (React.createElement(DataImportWizard_1.DataImportWizard, { onClose: () => {
                setIsWizardOpen(false);
                if (props?.popupParams == undefined ||
                    ['Toolbar', 'ContextMenu', 'ColumnMenu', 'ModuleButton'].includes(props?.popupParams?.source)) {
                    props.onClosePopup();
                }
            } }))));
};
exports.DataImportPopup = DataImportPopup;
