import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import Button from '../Button';
import Typography from '../Typography';
import Select from '../Select';
import Form from '../Form/Forms';
import './Table.scss';
const ifFailedOptionList = [
    {
        label: 'Mark this script as Failed and continue dependant script execution',
        value: 'MARK_THIS_SCRIPT_AS_FAILED_AND_CONTINUE_DEPENDANT_SCRIPT_EXECUTION',
    },
    {
        label: 'Mark this script as Warning and continue dependant script execution',
        value: 'MARK_THIS_SCRIPT_AS_WARNING_AND_CONTINUE_DEPENDANT_SCRIPT_EXECUTION',
    },
    {
        label: 'Mark this script as Failed and stop dependant script execution',
        value: 'MARK_THIS_SCRIPT_AS_FAILED_AND_STOP_DEPENDANT_SCRIPT_EXECUTION',
    },
    {
        label: 'Mark this script as Failed and stop current module execution',
        value: 'MARK_THIS_SCRIPT_AS_FAILED_AND_STOP_CURRENT_MODULE_EXECUTION',
    },
    {
        label: 'Mark this script as Failed and stop complete execution',
        value: 'MARK_THIS_SCRIPT_AS_FAILED_AND_STOP_COMPLETE_EXECUTION',
    },
];
//DEMO COMPONENT
const EditComponent = ({ rowData, rowIndex, handleSave, handleCancel, }) => {
    const [initialFormState] = useState({
        ifFailed: '',
    });
    return (_jsxs("section", { className: 'edit_depends_on_script', children: [_jsxs("header", { className: 'edit_depends_on_script__header', children: [_jsx("div", { children: _jsxs(Typography, { color: "var(--nlp-option-color)", lineHeight: "18px", children: [rowIndex, ".", rowData?.name] }) }), _jsx("div", { className: 'edit_depends_on_script__header__link', children: _jsx(Typography, { children: "Go to script", color: "var(--nlp-color)", fontWeight: "semi-bold" }) })] }), _jsx(Form, { onSubmit: handleSave, defaultValues: initialFormState, children: ({ register, setValue, formState: { errors }, watch, trigger }) => {
                    return (_jsxs("div", { className: 'edit_depends_on_script__form', children: [_jsx(Select, { label: "if Failed", optionsList: ifFailedOptionList, ...register('ifFailed'), onChange: (option) => {
                                    setValue('ifFailed', option.label);
                                }, errorMsg: errors.ifFailed?.message, optionZIndex: 9999, selectedOption: {
                                    label: watch('ifFailed'),
                                    value: watch('ifFailed'),
                                }, onBlur: () => {
                                    trigger('ifFailed');
                                } }), _jsxs("div", { className: 'edit_depends_on_script__form__button', children: [_jsx(Button, { variant: "tertiary", children: "Cancel", onClick: handleCancel }), _jsx(Button, { variant: "primary", type: "submit", children: "Update" })] })] }));
                } })] }));
};
export default EditComponent;
//# sourceMappingURL=EditComponent.js.map