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,
});
}

View File

@@ -24,6 +24,8 @@ import {
selectBodyshop,
selectInstanceConflict,
} from "../../redux/user/user.selectors";
import * as Sentry from "@sentry/react";
import "./manage.page.styles.scss";
const ManageRootPage = lazy(() =>
@@ -407,7 +409,10 @@ export function Manage({ match, conflict, bodyshop }) {
<Content className="content-container">
<PartnerPingComponent />
<ErrorBoundary>{PageContent}</ErrorBoundary>
<Sentry.ErrorBoundary fallback={<ErrorBoundary />} showDialog>
{PageContent}
</Sentry.ErrorBoundary>
<BackTop />
<Footer>
<div

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "You must allow notification permissions to have real time messaging. Click to try again.",
"notfound": "No record was found."
"notfound": "No record was found.",
"sizelimit": "The selected items exceed the size limit."
},
"itemtypes": {
"contract": "CC Contract",

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "",
"notfound": ""
"notfound": "",
"sizelimit": ""
},
"itemtypes": {
"contract": "",

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "",
"notfound": ""
"notfound": "",
"sizelimit": ""
},
"itemtypes": {
"contract": "",

View File

@@ -103,7 +103,7 @@ export default async function RenderTemplate(
}),
},
};
console.log("PDFREQ", pdfRequest);
const pdfRender = await jsreport.renderAsync(pdfRequest);
pdf = pdfRender.toDataURI();
}