import React, { useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import UdpTransactionTypeTransactionActionForm from '../forms/UdpTransactionTypeTransactionActionForm';
import { SideSheet } from '../../../../UI';
const UdpTransactionTypeTransactionActionCreateAndEditSidesheet = (props) => {
    const { initialTransactionTypeTransactionAction, isSideSheetOpen, handleSideSheet, handleCreateTransactionTypeTransactionAction, handleUpdateTransactionTypeTransactionAction, transactionActions, catalogObjectProperties, actionApis, pages, transactionTypeStatusOptions } = props;
    const isEditing = !!initialTransactionTypeTransactionAction;
    const formRef = useRef();
    const { t } = useTranslation();
    const onSubmitForm = useCallback(async (values, initialData) => {
        if (initialData) {
            await handleUpdateTransactionTypeTransactionAction(values, initialData);
        }
        else {
            await handleCreateTransactionTypeTransactionAction(values);
        }
    }, [handleCreateTransactionTypeTransactionAction, handleUpdateTransactionTypeTransactionAction]);
    return (React.createElement(SideSheet, { open: isSideSheetOpen, width: 600, title: isEditing ? t('Edit Action') : t('Create Action'), onClose: () => handleSideSheet(false), buttonLabel: isEditing ? t('Save') : t('Create'), onSubmit: () => {
            var _a;
            // eslint-disable-next-line no-unused-expressions
            (_a = formRef === null || formRef === void 0 ? void 0 : formRef.current) === null || _a === void 0 ? void 0 : _a.submit();
        } }, React.createElement(UdpTransactionTypeTransactionActionForm, { ref: formRef, onSubmit: onSubmitForm, initialData: initialTransactionTypeTransactionAction, transactionActionOptions: transactionActions, catalogObjectProperties: catalogObjectProperties, actionApiOptions: actionApis, pageOptions: pages, transactionTypeStatusOptions: transactionTypeStatusOptions })));
};
export default UdpTransactionTypeTransactionActionCreateAndEditSidesheet;
//# sourceMappingURL=UdpTransactionTypeTransactionActionCreateAndEditSidesheet.js.map