"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormEditUI = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const StyledButton_1 = require("../../../CommonUI/BuildlingBlocks/StyledButton");
const UILayer_1 = require("../../../CommonUI/BuildlingBlocks/UILayer");
const FormBuilder_1 = require("../../../Form/FormBuilder");
const FormEditUI = ({ onSave, form: propform, name, onClose, dataDefinition, onFormNameUpdate, }) => {
    const [open, setOpen] = react_1.default.useState(false);
    const [form, setForm] = react_1.default.useState(propform);
    const onFormSave = () => {
        setOpen(false);
        onSave(form.getStorageData());
    };
    const onFormClose = () => {
        setOpen(false);
        setForm(propform);
        onClose();
    };
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StyledButton_1.StyledButton, { color: "primary", variant: "contained", onClick: () => setOpen(true), children: "Edit Form" }), (0, jsx_runtime_1.jsx)(UILayer_1.UILayer, { open: open, maxWidth: false, fullScreen: true, padding: "0px 0px", renderUI: () => ((0, jsx_runtime_1.jsx)(FormBuilder_1.FormBuilder, { form: form, formName: name, onFormSave: onFormSave, onFormClose: onFormClose, onFormNameUpdate: onFormNameUpdate, dataDefinition: dataDefinition ? () => dataDefinition : undefined })), onClose: () => setOpen(false) })] }));
};
exports.FormEditUI = FormEditUI;
//# sourceMappingURL=FormEditUI.js.map