import React, { useCallback, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Field } from '../../utilities/form';
import { CkRichEditor } from '../inputs/richEditors';
import { AmbientAutoComplete, AmbientTextField } from '../inputs/textField';
import { useForm } from '../../utilities/form';
import { LayoutUnit } from '../../layout';
import { useUser } from '../../utilities/auth';
import { useTenantStore } from '../../stores';
export const UdpTransactionEmailForm = ({ existingTransactionAttachments, toOptions, ccOptions, toLabelFunction, toGroupBy, toFilterOptions, ccLabelFunction, ccGroupBy, ccFilterOptions, attachmentsLabelFunction, toInitialValue = [], ccInitialValue = [], existingTransactionAttachmentsInitialValue = [], subjectInitialValue = '', body = '', udpTransactionId }) => {
    const i18n = useTranslation().t;
    const form = useForm();
    const user = useUser();
    const currentTenant = useTenantStore((state) => state.currentTenant);
    const handleOnBodyChange = useCallback((value) => {
        form.change('body', value);
    }, [form]);
    useEffect(() => {
        form.change('body', body);
    }, [body, form]);
    return (React.createElement(React.Fragment, null, React.createElement(Field, { component: AmbientAutoComplete, name: "to", margin: "normal", variant: "outlined", isMultiple: true, options: toOptions, getOptionLabelFunction: toLabelFunction, groupBy: toGroupBy, filterOptions: toFilterOptions, label: i18n('To'), required: true, initialValue: toInitialValue }), React.createElement(Field, { component: AmbientAutoComplete, name: "cc", margin: "normal", variant: "outlined", isMultiple: true, options: ccOptions, getOptionLabelFunction: ccLabelFunction, groupBy: ccGroupBy, filterOptions: ccFilterOptions, label: i18n('Cc'), initialValue: ccInitialValue }), React.createElement(Field, { component: AmbientAutoComplete, name: "attachments", margin: "normal", variant: "outlined", isMultiple: true, options: existingTransactionAttachments, getOptionLabelFunction: attachmentsLabelFunction, label: i18n('Attachments'), initialValue: existingTransactionAttachmentsInitialValue }), React.createElement(Field, { component: AmbientTextField, name: "subject", margin: "normal", variant: "outlined", label: i18n('Subject'), required: true, initialValue: subjectInitialValue }), React.createElement(LayoutUnit, { unit: "nudge" }), React.createElement(CkRichEditor, { name: "body", handleChange: handleOnBodyChange, data: body }), React.createElement(Field, { component: AmbientTextField, name: "senderName", margin: "normal", variant: "outlined", label: i18n('Sender Name'), required: true, initialValue: (user === null || user === void 0 ? void 0 : user.name) || '', style: { display: 'none' } }), React.createElement(Field, { component: AmbientTextField, name: "currentTenantName", margin: "normal", variant: "outlined", label: i18n('Current Tenant Name'), required: true, initialValue: (currentTenant === null || currentTenant === void 0 ? void 0 : currentTenant.name) || '', style: { display: 'none' } }), React.createElement(Field, { component: AmbientTextField, name: "udpTransactionId", margin: "normal", variant: "outlined", label: i18n('UDP Transaction ID'), required: true, initialValue: udpTransactionId || '', style: { display: 'none' } })));
};
//# sourceMappingURL=UdpTransactionEmailForm.js.map