Skip to content

🔥 The free & Open Source DocuSign alternative

fix: remove type parameter from parse.save method

prafull-opensignlabs20752161d3d9
diff --git a/apps/OpenSign/src/pages/Form.jsx b/apps/OpenSign/src/pages/Form.jsx
index dd3f66123..78dd25c4d 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 && (
<div
style={{
- height:
- props.title === "New Template"
- ? "100px"
- : "280px"
+ height: props.title === "New Template" ? "100px" : "280px"
}}
className="w-[1px] bg-gray-300 m-auto hidden md:inline-block"
></div>
@@ -1172,11 +1163,7 @@ const Forms = (props) => {
</Tooltip>
</label>
<div className="flex flex-col md:flex-row md:gap-4">
- <div
- className={
- `flex items-center gap-2 ml-2 mb-1`
- }
- >
+ <div className={`flex items-center gap-2 ml-2 mb-1`}>
<input
className="mr-[2px] op-radio op-radio-xs"
type="radio"
@@ -1185,11 +1172,7 @@ const Forms = (props) => {
/>
<div className="text-center">{t("yes")}</div>
</div>
- <div
- className={
- `flex items-center gap-2 ml-2 mb-1`
- }
- >
+ <div className={`flex items-center gap-2 ml-2 mb-1`}>
<input
className="mr-[2px] op-radio op-radio-xs"
type="radio"
diff --git a/apps/OpenSign/src/pages/UserProfile.jsx b/apps/OpenSign/src/pages/UserProfile.jsx
index c35da27a1..483cb80c1 100644
--- a/apps/OpenSign/src/pages/UserProfile.jsx
+++ b/apps/OpenSign/src/pages/UserProfile.jsx
@@ -1,7 +1,4 @@
-import React, {
- useState,
- useEffect,
-} from "react";
+import React, { useState, useEffect } from "react";
import { Navigate, useNavigate } from "react-router";
import Parse from "parse";
import { SaveFileSize } from "../constant/saveFileSize";
@@ -9,10 +6,7 @@ import dp from "../assets/images/dp.png";
import { sanitizeFileName } from "../utils";
import axios from "axios";
import Tooltip from "../primitives/Tooltip";
-import {
- getSecureUrl,
- handleSendOTP,
-} from "../constant/Utils";
+import { getSecureUrl, handleSendOTP } from "../constant/Utils";
import ModalUi from "../primitives/ModalUi";
import Loader from "../primitives/Loader";
import { useTranslation } from "react-i18next";
@@ -133,7 +127,7 @@ function UserProfile() {
Name: obj.Name,
JobTitle: jobTitle,
Company: company,
- Language: obj?.language || "",
+ Language: obj?.language || ""
};
await axios.put(
@@ -172,8 +166,8 @@ function UserProfile() {
try {
const response = await parseFile.save({
- progress: (progressValue, loaded, total, { type }) => {
- 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() {
<button
type="button"
onClick={(e) => {
- editmode ? handleSubmit(e) : setEditMode(true);
+ editmode ? handleSubmit(e) : setEditMode(true);
}}
className="op-btn op-btn-primary md:w-[100px]"
>
@@ -460,9 +454,7 @@ function UserProfile() {
onClick={() =>
editmode ? handleCancel() : navigate("/changepassword")
}
- className={
- `op-btn ${editmode ? "op-btn-ghost w-[100px]" : "op-btn-secondary"}`
- }
+ className={`op-btn ${editmode ? "op-btn-ghost w-[100px]" : "op-btn-secondary"}`}
>
{editmode ? t("cancel") : t("change-password")}
</button>