From 20752161d3d967b98e9418dcad288447d1b6fdc6 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Thu, 20 Nov 2025 20:08:06 +0530 Subject: [PATCH] fix: remove type parameter from parse.save method --- apps/OpenSign/src/pages/Form.jsx | 173 +++++++++++------------- apps/OpenSign/src/pages/UserProfile.jsx | 22 +-- 2 files changed, 85 insertions(+), 110 deletions(-) diff --git a/apps/OpenSign/src/pages/Form.jsx b/apps/OpenSign/src/pages/Form.jsx index dd3f66123d..78dd25c4d4 100644 --- a/apps/OpenSign/src/pages/Form.jsx +++ b/apps/OpenSign/src/pages/Form.jsx @@ -46,8 +46,7 @@ function Form() { } const Forms = (props) => { - const appName = - "OpenSign™"; + const appName = "OpenSign™"; const { t } = useTranslation(); const abortController = new AbortController(); const inputFileRef = useRef(null); @@ -70,7 +69,7 @@ const Forms = (props) => { NotifyOnSignatures: "", Bcc: [], RedirectUrl: "", - AllowModifications: false, + AllowModifications: false }); const [fileupload, setFileUpload] = useState(""); const [selectedFiles, setSelectedFiles] = useState([]); @@ -101,8 +100,7 @@ const Forms = (props) => { extUserData?.IsTourEnabled === false ? "false" : "true"; - const fileSize = - maxFileSize; + const fileSize = maxFileSize; useEffect(() => { handleReset(); return () => abortController.abort(); @@ -114,12 +112,12 @@ const Forms = (props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const initializeValues = async () => { - setFormData((obj) => ({ - ...obj, - NotifyOnSignatures: true, - SendinOrder: sendinorder, - IsTourEnabled: istourenabled - })); + setFormData((obj) => ({ + ...obj, + NotifyOnSignatures: true, + SendinOrder: sendinorder, + IsTourEnabled: istourenabled + })); }; // `removeFile` is used to reset progress, percentage and remove file if exists @@ -278,8 +276,7 @@ const Forms = (props) => { setfileload(false); removeFile(e); console.log("err in docx to pdf ", err); - const error = - t("docx-error"); + const error = t("docx-error"); if (err?.code === 209) { dispatch(sessionStatus(false)); } else { @@ -308,25 +305,25 @@ const Forms = (props) => { const name = generatePdfName(16); const pdfName = `${name}.pdf`; let uploadedUrl = ""; - const parseFile = new Parse.File( - pdfName, - [...pdfBytes], - "application/pdf" - ); - const response = await parseFile.save({ - progress: (progressValue, loaded, total, { type }) => { - if (type === "upload" && progressValue !== null) { - const percentCompleted = Math.round((loaded * 100) / total); - setpercentage(percentCompleted); - } - } - }); - if (response.url()) { - const fileRes = await getSecureUrl(response.url()); - if (fileRes.url) { - uploadedUrl = fileRes.url; + const parseFile = new Parse.File( + pdfName, + [...pdfBytes], + "application/pdf" + ); + const response = await parseFile.save({ + progress: (progressValue, loaded, total) => { + if (progressValue !== null) { + const percentCompleted = Math.round((loaded * 100) / total); + setpercentage(percentCompleted); } } + }); + if (response.url()) { + const fileRes = await getSecureUrl(response.url()); + if (fileRes.url) { + uploadedUrl = fileRes.url; + } + } if (uploadedUrl) { const tenantId = localStorage.getItem("TenantId"); const userId = extUserData?.UserId?.objectId; @@ -388,16 +385,13 @@ const Forms = (props) => { object.set("Description", formData?.Description); object.set("Note", formData?.Note); if (props.title === "Request Signatures") { - if ( - extUserData?.TenantId?.RequestBody && - extUserData?.TenantId?.RequestSubject - ) { - object.set("RequestBody", extUserData?.TenantId?.RequestBody); - object.set( - "RequestSubject", - extUserData?.TenantId?.RequestSubject - ); - } + if ( + extUserData?.TenantId?.RequestBody && + extUserData?.TenantId?.RequestSubject + ) { + object.set("RequestBody", extUserData?.TenantId?.RequestBody); + object.set("RequestSubject", extUserData?.TenantId?.RequestSubject); + } } if (props.title !== "Sign Yourself") { const isChecked = formData.SendinOrder === "false" ? false : true; @@ -416,11 +410,11 @@ const Forms = (props) => { object.set("RemindOnceInEvery", remindOnceInEvery); object.set("IsTourEnabled", isTourEnabled); object.set("TimeToCompleteDays", TimeToCompleteDays); - object.set("AllowModifications", false); - object.set("IsEnableOTP", false); - if (formData.NotifyOnSignatures !== undefined) { - object.set("NotifyOnSignatures", formData.NotifyOnSignatures); - } + object.set("AllowModifications", false); + object.set("IsEnableOTP", false); + if (formData.NotifyOnSignatures !== undefined) { + object.set("NotifyOnSignatures", formData.NotifyOnSignatures); + } if (formData?.RedirectUrl) { object.set("RedirectUrl", formData.RedirectUrl); } @@ -457,9 +451,9 @@ const Forms = (props) => { setBcc([]); setFolder({ ObjectId: "", Name: "" }); const notifySign = - extUserData?.NotifyOnSignatures !== undefined - ? extUserData?.NotifyOnSignatures - : true; + extUserData?.NotifyOnSignatures !== undefined + ? extUserData?.NotifyOnSignatures + : true; setFormData({ Name: "", Description: "", @@ -477,7 +471,7 @@ const Forms = (props) => { IsEnableOTP: "false", IsTourEnabled: istourenabled, RedirectUrl: "", - AllowModifications: false, + AllowModifications: false }); setFileUpload(""); setSelectedFiles([]); @@ -539,9 +533,9 @@ const Forms = (props) => { setBcc([]); setFolder({ ObjectId: "", Name: "" }); const notifySign = - extUserData?.NotifyOnSignatures !== undefined - ? extUserData?.NotifyOnSignatures - : true; + extUserData?.NotifyOnSignatures !== undefined + ? extUserData?.NotifyOnSignatures + : true; let obj = { Name: "", Description: "", @@ -559,7 +553,7 @@ const Forms = (props) => { IsTourEnabled: istourenabled, NotifyOnSignatures: notifySign, RedirectUrl: "", - AllowModifications: false, + AllowModifications: false }; setFormData(obj); removeFile(); @@ -581,35 +575,27 @@ const Forms = (props) => { const name = generatePdfName(16); const pdfFile = await decryptPdf(formData?.file, formData?.password); setIsDecrypting(false); - const res = await getFileAsArrayBuffer(pdfFile); - const flatPdf = await flattenPdf(res); - const parseFile = new Parse.File(name, [...flatPdf], "application/pdf"); - await parseFile.save({ - progress: (progressValue, loaded, total, { type }) => { - if (type === "upload" && progressValue !== null) { - const percentCompleted = Math.round((loaded * 100) / total); - setpercentage(percentCompleted); - } - } - }); - // Retrieve the URL of the uploaded file - if (parseFile.url()) { - const fileRes = await getSecureUrl(parseFile.url()); - if (fileRes.url) { - setFileUpload(fileRes.url); - removeFile(); - const title = generateTitleFromFilename(formData?.file?.name); - setFormData((obj) => ({ ...obj, password: "", Name: title })); - SaveFileSize(size, fileRes?.url, tenantId, userId); - return fileRes.url; - } else { - removeFile(); - setFormData((prev) => ({ ...prev, password: "" })); - setIsDecrypting(false); - if (inputFileRef.current) { - inputFileRef.current.value = ""; // Set file input value to empty string - } + const res = await getFileAsArrayBuffer(pdfFile); + const flatPdf = await flattenPdf(res); + const parseFile = new Parse.File(name, [...flatPdf], "application/pdf"); + await parseFile.save({ + progress: (progressValue, loaded, total) => { + if (progressValue !== null) { + const percentCompleted = Math.round((loaded * 100) / total); + setpercentage(percentCompleted); } + } + }); + // Retrieve the URL of the uploaded file + if (parseFile.url()) { + const fileRes = await getSecureUrl(parseFile.url()); + if (fileRes.url) { + setFileUpload(fileRes.url); + removeFile(); + const title = generateTitleFromFilename(formData?.file?.name); + setFormData((obj) => ({ ...obj, password: "", Name: title })); + SaveFileSize(size, fileRes?.url, tenantId, userId); + return fileRes.url; } else { removeFile(); setFormData((prev) => ({ ...prev, password: "" })); @@ -618,6 +604,14 @@ const Forms = (props) => { inputFileRef.current.value = ""; // Set file input value to empty string } } + } else { + removeFile(); + setFormData((prev) => ({ ...prev, password: "" })); + setIsDecrypting(false); + if (inputFileRef.current) { + inputFileRef.current.value = ""; // Set file input value to empty string + } + } } catch (err) { removeFile(); if (err?.code === 209) { @@ -1060,10 +1054,7 @@ const Forms = (props) => { {isAdvanceOpt && (
@@ -1172,11 +1163,7 @@ const Forms = (props) => {
-
+
{ />
{t("yes")}
-
+
{ - if (type === "upload" && progressValue !== null) { + progress: (progressValue, loaded, total) => { + if (progressValue !== null) { const percentCompleted = Math.round((loaded * 100) / total); // console.log("percentCompleted ", percentCompleted); setpercentage(percentCompleted); @@ -449,7 +443,7 @@ function UserProfile() {