import { UploadOutlined, UserAddOutlined } from "@ant-design/icons"; import { Button, Divider, Dropdown, Form, Input, Select, Space, Tabs, Upload } from "antd"; import _ from "lodash"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectEmailConfig } from "../../redux/email/email.selectors"; import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors"; import { CreateExplorerLinkForJob } from "../../utils/localmedia"; import EmailDocumentsComponent from "../email-documents/email-documents.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, currentUser: selectCurrentUser, emailConfig: selectEmailConfig }); const mapDispatchToProps = () => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect(mapStateToProps, mapDispatchToProps)(EmailOverlayComponent); export function EmailOverlayComponent({ emailConfig, form, selectedMediaState, bodyshop, currentUser }) { const { t } = useTranslation(); const handleClick = ({ item }) => { const email = item.props.value; form.setFieldsValue({ to: _.uniq([...form.getFieldValue("to"), ...(typeof email === "string" ? [email] : email)]) }); }; const handle_CC_Click = ({ item }) => { const email = item.props.value; form.setFieldsValue({ cc: _.uniq([...(form.getFieldValue("cc") || ""), ...(typeof email === "string" ? [email] : email)]) }); }; const emailsToMenu = { items: [ ...bodyshop.employees .filter((e) => e.user_email && e.active === true) .map((e, idx) => ({ key: idx, label: `${e.first_name} ${e.last_name}`, value: e.user_email })), ...bodyshop.md_to_emails.map((e, idx) => ({ key: idx + "group", label: e.label, value: e.emails })) ], onClick: handleClick }; const menuCC = { items: [ ...bodyshop.employees .filter((e) => e.user_email && e.active === true) .map((e, idx) => ({ key: idx, label: `${e.first_name} ${e.last_name}`, value: e.user_email })), ...bodyshop.md_to_emails.map((e, idx) => ({ key: idx + "group", label: e.label, value: e.emails })) ], onClick: handle_CC_Click }; return (
{t("emails.fields.cc")} e.preventDefault()}> } name="cc" > {t("emails.labels.preview")} {bodyshop.attach_pdf_to_email && {t("emails.labels.pdfcopywillbeattached")}} {() => { return (
); }} }, { key: "attachments", label: t("emails.labels.attachments"), children: ( <> {bodyshop.uselocalmediaserver && emailConfig.jobid && ( )} { if (Array.isArray(e)) { return e; } return e && e.fileList; }} rules={[ () => ({ validator(rule, value) { const totalSize = value.reduce((acc, val) => (acc = acc + val.size), 0); const limit = 10485760 - new Blob([form.getFieldValue("html")]).size; if (totalSize > limit) { return Promise.reject(t("general.errors.sizelimit")); } return Promise.resolve(); } }) ]} > <>

Click or drag files to this area to upload.

) } ]} />
); }