IO-1937 Add 10mb limit for emails.

This commit is contained in:
Patrick Fic
2022-06-17 15:22:29 -07:00
parent 7ba3cc5ffa
commit 1e88d5ae1b
13 changed files with 15461 additions and 3334 deletions

View File

@@ -38,6 +38,12 @@ export function EmailDocumentsComponent({
nextFetchPolicy: "network-only",
});
console.log(
selectedMedia &&
selectedMedia
.filter((s) => s.isSelected)
.reduce((acc, val) => (acc = acc + val.size), 0)
);
return (
<div>
{loading && <LoadingSpinner />}
@@ -45,6 +51,12 @@ export function EmailDocumentsComponent({
{selectedMedia.filter((s) => s.isSelected).length >= 10 ? (
<div style={{ color: "red" }}>{t("messaging.labels.maxtenimages")}</div>
) : null}
{selectedMedia &&
selectedMedia
.filter((s) => s.isSelected)
.reduce((acc, val) => (acc = acc + val.size), 0) >= 9961472 ? (
<div style={{ color: "red" }}>{t("general.errors.sizelimit")}</div>
) : null}
{data && (
<JobDocumentsGalleryExternal
data={data ? data.documents : []}

View File

@@ -180,6 +180,23 @@ export function EmailOverlayComponent({
}
return e && e.fileList;
}}
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
const totalSize = value.reduce(
(acc, val) => (acc = acc + val.size),
0
);
const limit = 9961472;
if (totalSize > limit) {
return Promise.reject(t("general.errors.sizelimit"));
}
return Promise.resolve();
},
}),
]}
>
<Upload.Dragger
beforeUpload={Upload.LIST_IGNORE}

View File

@@ -30,6 +30,7 @@ class ErrorBoundary extends React.Component {
static getDerivedStateFromError(error) {
console.log("ErrorBoundary -> getDerivedStateFromError -> error", error);
return { hasErrored: true, error: error };
}

View File

@@ -25,6 +25,7 @@ function JobsDocumentGalleryExternal({
id: value.id,
type: value.type,
tags: [{ value: value.type, title: value.type }],
size: value.size,
});
}