Skip to content

Commit 3c8b883

Browse files
authored
Merge pull request #2029 from OpenSignLabs/build_deps
fix: remove type parameter from parse.save method
2 parents 002b0d5 + 2075216 commit 3c8b883

File tree

2 files changed

+85
-110
lines changed

2 files changed

+85
-110
lines changed

apps/OpenSign/src/pages/Form.jsx

Lines changed: 78 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ function Form() {
4646
}
4747

4848
const Forms = (props) => {
49-
const appName =
50-
"OpenSign™";
49+
const appName = "OpenSign™";
5150
const { t } = useTranslation();
5251
const abortController = new AbortController();
5352
const inputFileRef = useRef(null);
@@ -70,7 +69,7 @@ const Forms = (props) => {
7069
NotifyOnSignatures: "",
7170
Bcc: [],
7271
RedirectUrl: "",
73-
AllowModifications: false,
72+
AllowModifications: false
7473
});
7574
const [fileupload, setFileUpload] = useState("");
7675
const [selectedFiles, setSelectedFiles] = useState([]);
@@ -101,8 +100,7 @@ const Forms = (props) => {
101100
extUserData?.IsTourEnabled === false
102101
? "false"
103102
: "true";
104-
const fileSize =
105-
maxFileSize;
103+
const fileSize = maxFileSize;
106104
useEffect(() => {
107105
handleReset();
108106
return () => abortController.abort();
@@ -114,12 +112,12 @@ const Forms = (props) => {
114112
// eslint-disable-next-line react-hooks/exhaustive-deps
115113
}, []);
116114
const initializeValues = async () => {
117-
setFormData((obj) => ({
118-
...obj,
119-
NotifyOnSignatures: true,
120-
SendinOrder: sendinorder,
121-
IsTourEnabled: istourenabled
122-
}));
115+
setFormData((obj) => ({
116+
...obj,
117+
NotifyOnSignatures: true,
118+
SendinOrder: sendinorder,
119+
IsTourEnabled: istourenabled
120+
}));
123121
};
124122

125123
// `removeFile` is used to reset progress, percentage and remove file if exists
@@ -278,8 +276,7 @@ const Forms = (props) => {
278276
setfileload(false);
279277
removeFile(e);
280278
console.log("err in docx to pdf ", err);
281-
const error =
282-
t("docx-error");
279+
const error = t("docx-error");
283280
if (err?.code === 209) {
284281
dispatch(sessionStatus(false));
285282
} else {
@@ -308,25 +305,25 @@ const Forms = (props) => {
308305
const name = generatePdfName(16);
309306
const pdfName = `${name}.pdf`;
310307
let uploadedUrl = "";
311-
const parseFile = new Parse.File(
312-
pdfName,
313-
[...pdfBytes],
314-
"application/pdf"
315-
);
316-
const response = await parseFile.save({
317-
progress: (progressValue, loaded, total, { type }) => {
318-
if (type === "upload" && progressValue !== null) {
319-
const percentCompleted = Math.round((loaded * 100) / total);
320-
setpercentage(percentCompleted);
321-
}
322-
}
323-
});
324-
if (response.url()) {
325-
const fileRes = await getSecureUrl(response.url());
326-
if (fileRes.url) {
327-
uploadedUrl = fileRes.url;
308+
const parseFile = new Parse.File(
309+
pdfName,
310+
[...pdfBytes],
311+
"application/pdf"
312+
);
313+
const response = await parseFile.save({
314+
progress: (progressValue, loaded, total) => {
315+
if (progressValue !== null) {
316+
const percentCompleted = Math.round((loaded * 100) / total);
317+
setpercentage(percentCompleted);
328318
}
329319
}
320+
});
321+
if (response.url()) {
322+
const fileRes = await getSecureUrl(response.url());
323+
if (fileRes.url) {
324+
uploadedUrl = fileRes.url;
325+
}
326+
}
330327
if (uploadedUrl) {
331328
const tenantId = localStorage.getItem("TenantId");
332329
const userId = extUserData?.UserId?.objectId;
@@ -388,16 +385,13 @@ const Forms = (props) => {
388385
object.set("Description", formData?.Description);
389386
object.set("Note", formData?.Note);
390387
if (props.title === "Request Signatures") {
391-
if (
392-
extUserData?.TenantId?.RequestBody &&
393-
extUserData?.TenantId?.RequestSubject
394-
) {
395-
object.set("RequestBody", extUserData?.TenantId?.RequestBody);
396-
object.set(
397-
"RequestSubject",
398-
extUserData?.TenantId?.RequestSubject
399-
);
400-
}
388+
if (
389+
extUserData?.TenantId?.RequestBody &&
390+
extUserData?.TenantId?.RequestSubject
391+
) {
392+
object.set("RequestBody", extUserData?.TenantId?.RequestBody);
393+
object.set("RequestSubject", extUserData?.TenantId?.RequestSubject);
394+
}
401395
}
402396
if (props.title !== "Sign Yourself") {
403397
const isChecked = formData.SendinOrder === "false" ? false : true;
@@ -416,11 +410,11 @@ const Forms = (props) => {
416410
object.set("RemindOnceInEvery", remindOnceInEvery);
417411
object.set("IsTourEnabled", isTourEnabled);
418412
object.set("TimeToCompleteDays", TimeToCompleteDays);
419-
object.set("AllowModifications", false);
420-
object.set("IsEnableOTP", false);
421-
if (formData.NotifyOnSignatures !== undefined) {
422-
object.set("NotifyOnSignatures", formData.NotifyOnSignatures);
423-
}
413+
object.set("AllowModifications", false);
414+
object.set("IsEnableOTP", false);
415+
if (formData.NotifyOnSignatures !== undefined) {
416+
object.set("NotifyOnSignatures", formData.NotifyOnSignatures);
417+
}
424418
if (formData?.RedirectUrl) {
425419
object.set("RedirectUrl", formData.RedirectUrl);
426420
}
@@ -457,9 +451,9 @@ const Forms = (props) => {
457451
setBcc([]);
458452
setFolder({ ObjectId: "", Name: "" });
459453
const notifySign =
460-
extUserData?.NotifyOnSignatures !== undefined
461-
? extUserData?.NotifyOnSignatures
462-
: true;
454+
extUserData?.NotifyOnSignatures !== undefined
455+
? extUserData?.NotifyOnSignatures
456+
: true;
463457
setFormData({
464458
Name: "",
465459
Description: "",
@@ -477,7 +471,7 @@ const Forms = (props) => {
477471
IsEnableOTP: "false",
478472
IsTourEnabled: istourenabled,
479473
RedirectUrl: "",
480-
AllowModifications: false,
474+
AllowModifications: false
481475
});
482476
setFileUpload("");
483477
setSelectedFiles([]);
@@ -539,9 +533,9 @@ const Forms = (props) => {
539533
setBcc([]);
540534
setFolder({ ObjectId: "", Name: "" });
541535
const notifySign =
542-
extUserData?.NotifyOnSignatures !== undefined
543-
? extUserData?.NotifyOnSignatures
544-
: true;
536+
extUserData?.NotifyOnSignatures !== undefined
537+
? extUserData?.NotifyOnSignatures
538+
: true;
545539
let obj = {
546540
Name: "",
547541
Description: "",
@@ -559,7 +553,7 @@ const Forms = (props) => {
559553
IsTourEnabled: istourenabled,
560554
NotifyOnSignatures: notifySign,
561555
RedirectUrl: "",
562-
AllowModifications: false,
556+
AllowModifications: false
563557
};
564558
setFormData(obj);
565559
removeFile();
@@ -581,35 +575,27 @@ const Forms = (props) => {
581575
const name = generatePdfName(16);
582576
const pdfFile = await decryptPdf(formData?.file, formData?.password);
583577
setIsDecrypting(false);
584-
const res = await getFileAsArrayBuffer(pdfFile);
585-
const flatPdf = await flattenPdf(res);
586-
const parseFile = new Parse.File(name, [...flatPdf], "application/pdf");
587-
await parseFile.save({
588-
progress: (progressValue, loaded, total, { type }) => {
589-
if (type === "upload" && progressValue !== null) {
590-
const percentCompleted = Math.round((loaded * 100) / total);
591-
setpercentage(percentCompleted);
592-
}
593-
}
594-
});
595-
// Retrieve the URL of the uploaded file
596-
if (parseFile.url()) {
597-
const fileRes = await getSecureUrl(parseFile.url());
598-
if (fileRes.url) {
599-
setFileUpload(fileRes.url);
600-
removeFile();
601-
const title = generateTitleFromFilename(formData?.file?.name);
602-
setFormData((obj) => ({ ...obj, password: "", Name: title }));
603-
SaveFileSize(size, fileRes?.url, tenantId, userId);
604-
return fileRes.url;
605-
} else {
606-
removeFile();
607-
setFormData((prev) => ({ ...prev, password: "" }));
608-
setIsDecrypting(false);
609-
if (inputFileRef.current) {
610-
inputFileRef.current.value = ""; // Set file input value to empty string
611-
}
578+
const res = await getFileAsArrayBuffer(pdfFile);
579+
const flatPdf = await flattenPdf(res);
580+
const parseFile = new Parse.File(name, [...flatPdf], "application/pdf");
581+
await parseFile.save({
582+
progress: (progressValue, loaded, total) => {
583+
if (progressValue !== null) {
584+
const percentCompleted = Math.round((loaded * 100) / total);
585+
setpercentage(percentCompleted);
612586
}
587+
}
588+
});
589+
// Retrieve the URL of the uploaded file
590+
if (parseFile.url()) {
591+
const fileRes = await getSecureUrl(parseFile.url());
592+
if (fileRes.url) {
593+
setFileUpload(fileRes.url);
594+
removeFile();
595+
const title = generateTitleFromFilename(formData?.file?.name);
596+
setFormData((obj) => ({ ...obj, password: "", Name: title }));
597+
SaveFileSize(size, fileRes?.url, tenantId, userId);
598+
return fileRes.url;
613599
} else {
614600
removeFile();
615601
setFormData((prev) => ({ ...prev, password: "" }));
@@ -618,6 +604,14 @@ const Forms = (props) => {
618604
inputFileRef.current.value = ""; // Set file input value to empty string
619605
}
620606
}
607+
} else {
608+
removeFile();
609+
setFormData((prev) => ({ ...prev, password: "" }));
610+
setIsDecrypting(false);
611+
if (inputFileRef.current) {
612+
inputFileRef.current.value = ""; // Set file input value to empty string
613+
}
614+
}
621615
} catch (err) {
622616
removeFile();
623617
if (err?.code === 209) {
@@ -1060,10 +1054,7 @@ const Forms = (props) => {
10601054
{isAdvanceOpt && (
10611055
<div
10621056
style={{
1063-
height:
1064-
props.title === "New Template"
1065-
? "100px"
1066-
: "280px"
1057+
height: props.title === "New Template" ? "100px" : "280px"
10671058
}}
10681059
className="w-[1px] bg-gray-300 m-auto hidden md:inline-block"
10691060
></div>
@@ -1172,11 +1163,7 @@ const Forms = (props) => {
11721163
</Tooltip>
11731164
</label>
11741165
<div className="flex flex-col md:flex-row md:gap-4">
1175-
<div
1176-
className={
1177-
`flex items-center gap-2 ml-2 mb-1`
1178-
}
1179-
>
1166+
<div className={`flex items-center gap-2 ml-2 mb-1`}>
11801167
<input
11811168
className="mr-[2px] op-radio op-radio-xs"
11821169
type="radio"
@@ -1185,11 +1172,7 @@ const Forms = (props) => {
11851172
/>
11861173
<div className="text-center">{t("yes")}</div>
11871174
</div>
1188-
<div
1189-
className={
1190-
`flex items-center gap-2 ml-2 mb-1`
1191-
}
1192-
>
1175+
<div className={`flex items-center gap-2 ml-2 mb-1`}>
11931176
<input
11941177
className="mr-[2px] op-radio op-radio-xs"
11951178
type="radio"

apps/OpenSign/src/pages/UserProfile.jsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import React, {
2-
useState,
3-
useEffect,
4-
} from "react";
1+
import React, { useState, useEffect } from "react";
52
import { Navigate, useNavigate } from "react-router";
63
import Parse from "parse";
74
import { SaveFileSize } from "../constant/saveFileSize";
85
import dp from "../assets/images/dp.png";
96
import { sanitizeFileName } from "../utils";
107
import axios from "axios";
118
import Tooltip from "../primitives/Tooltip";
12-
import {
13-
getSecureUrl,
14-
handleSendOTP,
15-
} from "../constant/Utils";
9+
import { getSecureUrl, handleSendOTP } from "../constant/Utils";
1610
import ModalUi from "../primitives/ModalUi";
1711
import Loader from "../primitives/Loader";
1812
import { useTranslation } from "react-i18next";
@@ -133,7 +127,7 @@ function UserProfile() {
133127
Name: obj.Name,
134128
JobTitle: jobTitle,
135129
Company: company,
136-
Language: obj?.language || "",
130+
Language: obj?.language || ""
137131
};
138132

139133
await axios.put(
@@ -172,8 +166,8 @@ function UserProfile() {
172166

173167
try {
174168
const response = await parseFile.save({
175-
progress: (progressValue, loaded, total, { type }) => {
176-
if (type === "upload" && progressValue !== null) {
169+
progress: (progressValue, loaded, total) => {
170+
if (progressValue !== null) {
177171
const percentCompleted = Math.round((loaded * 100) / total);
178172
// console.log("percentCompleted ", percentCompleted);
179173
setpercentage(percentCompleted);
@@ -449,7 +443,7 @@ function UserProfile() {
449443
<button
450444
type="button"
451445
onClick={(e) => {
452-
editmode ? handleSubmit(e) : setEditMode(true);
446+
editmode ? handleSubmit(e) : setEditMode(true);
453447
}}
454448
className="op-btn op-btn-primary md:w-[100px]"
455449
>
@@ -460,9 +454,7 @@ function UserProfile() {
460454
onClick={() =>
461455
editmode ? handleCancel() : navigate("/changepassword")
462456
}
463-
className={
464-
`op-btn ${editmode ? "op-btn-ghost w-[100px]" : "op-btn-secondary"}`
465-
}
457+
className={`op-btn ${editmode ? "op-btn-ghost w-[100px]" : "op-btn-secondary"}`}
466458
>
467459
{editmode ? t("cancel") : t("change-password")}
468460
</button>

0 commit comments

Comments
 (0)