+ {loading &&
}
+ {error &&
}
+ {selectedMedia.filter((s) => s.isSelected).length >= 10 ? (
+
{t("messaging.labels.maxtenimages")}
+ ) : null}
+ {data && (
+
+ )}
+
+ );
+}
diff --git a/client/src/components/email-overlay/email-overlay.component.jsx b/client/src/components/email-overlay/email-overlay.component.jsx
index 0e21bfbb4..3f6f8f72c 100644
--- a/client/src/components/email-overlay/email-overlay.component.jsx
+++ b/client/src/components/email-overlay/email-overlay.component.jsx
@@ -1,9 +1,10 @@
import { UploadOutlined } from "@ant-design/icons";
-import { Card, Divider, Form, Input, Select, Upload } from "antd";
+import { Divider, Form, Input, Select, Tabs, Upload } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
+import EmailDocumentsComponent from "../email-documents/email-documents.component";
-export default function EmailOverlayComponent({ form }) {
+export default function EmailOverlayComponent({ form, selectedMediaState }) {
const { t } = useTranslation();
return (
@@ -52,34 +53,38 @@ export default function EmailOverlayComponent({ form }) {
}}
-
- {
- console.log("Upload event:", e);
- if (Array.isArray(e)) {
- return e;
- }
- return e && e.fileList;
- }}
- >
-
+
+
+
+
+ {
+ if (Array.isArray(e)) {
+ return e;
+ }
+ return e && e.fileList;
+ }}
>
- <>
-
-
-
-
- Click or drag files to this area to upload.
-
- >
-
-
-
+
+ <>
+
+
+
+
+ Click or drag files to this area to upload.
+
+ >
+
+
+
+
);
}
diff --git a/client/src/components/email-overlay/email-overlay.container.jsx b/client/src/components/email-overlay/email-overlay.container.jsx
index 4010d68ee..e776a156e 100644
--- a/client/src/components/email-overlay/email-overlay.container.jsx
+++ b/client/src/components/email-overlay/email-overlay.container.jsx
@@ -43,6 +43,8 @@ export function EmailOverlayContainer({
const [loading, setLoading] = useState(false);
const [sending, setSending] = useState(false);
const [rawHtml, setRawHtml] = useState("");
+ const [selectedMedia, setSelectedMedia] = useState([]);
+
const defaultEmailFrom = {
from: {
name: `${currentUser.displayName} @ ${bodyshop.shopname}`,
@@ -56,17 +58,18 @@ export function EmailOverlayContainer({
const handleFinish = async (values) => {
logImEXEvent("email_send_from_modal");
- console.log(`values`, values);
+
const attachments = [];
- await asyncForEach(values.fileList, async (f) => {
- const t = {
- ContentType: f.type,
- Filename: f.name,
- Base64Content: (await toBase64(f.originFileObj)).split(",")[1],
- };
- attachments.push(t);
- });
+ if (values.fileList)
+ await asyncForEach(values.fileList, async (f) => {
+ const t = {
+ ContentType: f.type,
+ Filename: f.name,
+ Base64Content: (await toBase64(f.originFileObj)).split(",")[1],
+ };
+ attachments.push(t);
+ });
setSending(true);
try {
@@ -74,9 +77,12 @@ export function EmailOverlayContainer({
...defaultEmailFrom,
...values,
html: rawHtml,
- attachments: await Promise.all(
- values.fileList.map(async (f) => await toBase64(f.originFileObj))
- ),
+ attachments:
+ values.fileList &&
+ (await Promise.all(
+ values.fileList.map(async (f) => await toBase64(f.originFileObj))
+ )),
+ media: selectedMedia.filter((m) => m.isSelected).map((m) => m.src),
//attachments,
});
notification["success"]({ message: t("emails.successes.sent") });
@@ -137,7 +143,12 @@ export function EmailOverlayContainer({