IO-557 Send documents in emails.
This commit is contained in:
@@ -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({
|
||||
<LoadingSpinner message={t("emails.labels.generatingemail")} />
|
||||
</div>
|
||||
)}
|
||||
{!loading && <EmailOverlayComponent form={form} />}
|
||||
{!loading && (
|
||||
<EmailOverlayComponent
|
||||
form={form}
|
||||
selectedMediaState={[selectedMedia, setSelectedMedia]}
|
||||
/>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user