Skip to content

Commit 5bd36f9

Browse files
Fix: issue with multiple linking user in quick send
1 parent c199c30 commit 5bd36f9

File tree

5 files changed

+623
-504
lines changed

5 files changed

+623
-504
lines changed

apps/OpenSign/src/pages/GuestLogin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ function GuestLogin() {
169169
e.preventDefault();
170170
const params = { ...contact, docId: documentId };
171171
try {
172+
setLoading(true);
172173
const linkContactRes = await Parse.Cloud.run("linkcontacttodoc", params);
173174
// console.log("linkContactRes ", linkContactRes);
174175
setContactId(linkContactRes.contactId);
175-
setLoading(true);
176176
setEnterOtp(true);
177177
await SendOtp();
178178
} catch (err) {

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 148 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ function PdfRequestFiles() {
274274
};
275275
setAlreadySign(true);
276276
setIsCompleted(data);
277+
setIsCelebration(true);
278+
setTimeout(() => {
279+
setIsCelebration(false);
280+
}, 5000);
277281
} else if (declined) {
278282
const currentDecline = {
279283
currnt: "another",
@@ -286,6 +290,13 @@ function PdfRequestFiles() {
286290
);
287291
setIsExpired(true);
288292
setExpiredDate(expireDateFormat);
293+
} // Check if the current signer is not a last signer and handle the complete message.
294+
else if (isNextUser) {
295+
setIsCompleted({
296+
isModal: true,
297+
message:
298+
"You have successfully signed the document. You can download or print a copy of the partially signed document. A copy of the digitally signed document will be sent to the owner over email once it is signed by all signers."
299+
});
289300
}
290301

291302
const isGuestSign = location.pathname.includes("/load/");
@@ -315,164 +326,157 @@ function PdfRequestFiles() {
315326
}
316327
}
317328
}
318-
if (documentData.length > 0) {
319-
const checkDocIdExist =
320-
documentData[0].AuditTrail &&
321-
documentData[0].AuditTrail.length > 0 &&
322-
documentData[0].AuditTrail.filter(
323-
(data) => data.Activity === "Signed"
324-
);
329+
const checkDocIdExist =
330+
documentData[0].AuditTrail &&
331+
documentData[0].AuditTrail.length > 0 &&
332+
documentData[0].AuditTrail.filter((data) => data.Activity === "Signed");
325333

326-
const checkAlreadySign =
327-
documentData[0].AuditTrail &&
328-
documentData[0].AuditTrail.length > 0 &&
329-
documentData[0].AuditTrail.filter(
330-
(data) =>
331-
data.UserPtr.objectId === currUserId && data.Activity === "Signed"
332-
);
334+
const checkAlreadySign =
335+
documentData[0].AuditTrail &&
336+
documentData[0].AuditTrail.length > 0 &&
337+
documentData[0].AuditTrail.filter(
338+
(data) =>
339+
data.UserPtr.objectId === currUserId && data.Activity === "Signed"
340+
);
341+
if (
342+
checkAlreadySign &&
343+
checkAlreadySign[0] &&
344+
checkAlreadySign.length > 0
345+
) {
346+
setAlreadySign(true);
347+
} else {
348+
const obj = documentData?.[0];
349+
setSendInOrder(obj?.SendinOrder || false);
333350
if (
334-
checkAlreadySign &&
335-
checkAlreadySign[0] &&
336-
checkAlreadySign.length > 0
351+
obj &&
352+
obj.Signers &&
353+
obj.Signers.length > 0 &&
354+
obj.Placeholders &&
355+
obj.Placeholders.length > 0
337356
) {
338-
setAlreadySign(true);
339-
} else {
340-
const obj = documentData?.[0];
341-
setSendInOrder(obj?.SendinOrder || false);
342-
if (
343-
obj &&
344-
obj.Signers &&
345-
obj.Signers.length > 0 &&
346-
obj.Placeholders &&
347-
obj.Placeholders.length > 0
348-
) {
349-
const params = {
350-
event: "viewed",
351-
contactId: currUserId,
352-
body: {
353-
objectId: documentData?.[0].objectId,
354-
file: documentData?.[0]?.SignedUrl || documentData?.[0]?.URL,
355-
name: documentData?.[0].Name,
356-
note: documentData?.[0].Note || "",
357-
description: documentData?.[0].Description || "",
358-
signers: documentData?.[0].Signers?.map((x) => ({
359-
name: x?.Name,
360-
email: x?.Email,
361-
phone: x?.Phone
362-
})),
363-
viewedBy: jsonSender.email,
364-
viewedAt: new Date(),
365-
createdAt: documentData?.[0].createdAt
366-
}
367-
};
357+
const params = {
358+
event: "viewed",
359+
contactId: currUserId,
360+
body: {
361+
objectId: documentData?.[0].objectId,
362+
file: documentData?.[0]?.SignedUrl || documentData?.[0]?.URL,
363+
name: documentData?.[0].Name,
364+
note: documentData?.[0].Note || "",
365+
description: documentData?.[0].Description || "",
366+
signers: documentData?.[0].Signers?.map((x) => ({
367+
name: x?.Name,
368+
email: x?.Email,
369+
phone: x?.Phone
370+
})),
371+
viewedBy: jsonSender.email,
372+
viewedAt: new Date(),
373+
createdAt: documentData?.[0].createdAt
374+
}
375+
};
368376

369-
try {
370-
await axios.post(
371-
`${localStorage.getItem("baseUrl")}functions/callwebhook`,
372-
params,
373-
{
374-
headers: {
375-
"Content-Type": "application/json",
376-
"X-Parse-Application-Id":
377-
localStorage.getItem("parseAppId"),
378-
sessiontoken: localStorage.getItem("accesstoken")
379-
}
377+
try {
378+
await axios.post(
379+
`${localStorage.getItem("baseUrl")}functions/callwebhook`,
380+
params,
381+
{
382+
headers: {
383+
"Content-Type": "application/json",
384+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
385+
sessiontoken: localStorage.getItem("accesstoken")
380386
}
381-
);
382-
} catch (err) {
383-
console.log("Err ", err);
384-
}
387+
}
388+
);
389+
} catch (err) {
390+
console.log("Err ", err);
385391
}
386392
}
393+
}
387394

388-
let signers = [];
389-
let unSignedSigner = [];
395+
let signers = [];
396+
let unSignedSigner = [];
390397

391-
//check document is signed or not
392-
if (checkDocIdExist && checkDocIdExist.length > 0) {
393-
setIsDocId(true);
394-
const signerRes = documentData[0].Signers;
395-
//comparison auditTrail user details with signers user details
396-
for (let i = 0; i < signerRes.length; i++) {
397-
const signerId = signerRes[i].objectId;
398+
//check document is signed or not
399+
if (checkDocIdExist && checkDocIdExist.length > 0) {
400+
setIsDocId(true);
401+
const signerRes = documentData[0].Signers;
402+
//comparison auditTrail user details with signers user details
403+
for (let i = 0; i < signerRes.length; i++) {
404+
const signerId = signerRes[i].objectId;
398405

399-
let isSignedSignature = false;
400-
for (let j = 0; j < checkDocIdExist.length; j++) {
401-
const signedExist =
402-
checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId;
403-
//checking signerObjId and auditTrail User objId
404-
// if match then add signed data in signer array and break loop
406+
let isSignedSignature = false;
407+
for (let j = 0; j < checkDocIdExist.length; j++) {
408+
const signedExist =
409+
checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId;
410+
//checking signerObjId and auditTrail User objId
411+
// if match then add signed data in signer array and break loop
405412

406-
if (signerId === signedExist) {
407-
signers.push({ ...signerRes[i], ...signerRes[i] });
408-
isSignedSignature = true;
409-
break;
410-
}
411-
// if does not match then add unsigned data in unSignedSigner array
412-
}
413-
if (!isSignedSignature) {
414-
unSignedSigner.push({ ...signerRes[i], ...signerRes[i] });
413+
if (signerId === signedExist) {
414+
signers.push({ ...signerRes[i], ...signerRes[i] });
415+
isSignedSignature = true;
416+
break;
415417
}
418+
// if does not match then add unsigned data in unSignedSigner array
416419
}
417-
setSignedSigners(signers);
418-
setUnSignedSigners(unSignedSigner);
419-
420-
setSignerPos(documentData[0].Placeholders);
421-
} else {
422-
let unsigned = [];
423-
for (let i = 0; i < documentData.length; i++) {
424-
unsigned.push(documentData[i].Signers);
420+
if (!isSignedSignature) {
421+
unSignedSigner.push({ ...signerRes[i], ...signerRes[i] });
425422
}
426-
setUnSignedSigners(unsigned[0]);
427-
setSignerPos(documentData[0].Placeholders);
428423
}
429-
setPdfDetails(documentData);
430-
// Check if the current signer is not a last signer and handle the complete message.
431-
if (isNextUser) {
432-
const getSignedAuditTrail = documentData[0].AuditTrail.filter(
433-
(data) => data.Activity === "Signed"
434-
);
435-
const isLastSigner =
436-
getSignedAuditTrail?.length === documentData?.[0]?.Signers?.length;
437-
if (!isLastSigner) {
438-
setIsCompleted({
439-
isModal: true,
440-
message:
441-
"You have successfully signed the document. You can download or print a copy of the partially signed document. A copy of the digitally signed document will be sent to the owner over email once it is signed by all signers."
442-
});
443-
} else {
444-
setIsCelebration(true);
445-
setTimeout(() => {
446-
setIsCelebration(false);
447-
}, 5000);
448-
}
424+
setSignedSigners(signers);
425+
setUnSignedSigners(unSignedSigner);
426+
setSignerPos(documentData[0].Placeholders);
427+
} else {
428+
let unsigned = [];
429+
for (let i = 0; i < documentData.length; i++) {
430+
unsigned.push(documentData[i].Signers);
449431
}
450-
//checking if condition current user already sign or owner does not exist as a signer or document has been declined by someone or document has been expired
451-
//then stop to display tour message
452-
if (
453-
(checkAlreadySign &&
454-
checkAlreadySign[0] &&
455-
checkAlreadySign.length > 0) ||
456-
!currUserId ||
457-
declined ||
458-
currDate > expireUpdateDate
459-
) {
460-
setRequestSignTour(false);
461-
} else {
462-
//else condition to check current user exist in contracts_Users class and check tour message status
463-
//if not then check user exist in contracts_Contactbook class and check tour message status
464-
const localuser = localStorage.getItem(
465-
`Parse/${appInfo.appId}/currentUser`
466-
);
467-
const currentUser = JSON.parse(JSON.stringify(localuser));
468-
const currentUserEmail = currentUser.email;
469-
const res = await contractUsers(currentUserEmail);
432+
setUnSignedSigners(unsigned[0]);
433+
setSignerPos(documentData[0].Placeholders);
434+
}
435+
setPdfDetails(documentData);
436+
//checking if condition current user already sign or owner does not exist as a signer or document has been declined by someone or document has been expired
437+
//then stop to display tour message
438+
if (
439+
(checkAlreadySign &&
440+
checkAlreadySign[0] &&
441+
checkAlreadySign.length > 0) ||
442+
!currUserId ||
443+
declined ||
444+
currDate > expireUpdateDate
445+
) {
446+
setRequestSignTour(false);
447+
} else {
448+
//else condition to check current user exist in contracts_Users class and check tour message status
449+
//if not then check user exist in contracts_Contactbook class and check tour message status
450+
const localuser = localStorage.getItem(
451+
`Parse/${appInfo.appId}/currentUser`
452+
);
453+
const currentUser = JSON.parse(JSON.stringify(localuser));
454+
const currentUserEmail = currentUser.email;
455+
const res = await contractUsers(currentUserEmail);
456+
if (res === "Error: Something went wrong!") {
457+
setHandleError("Error: Something went wrong!");
458+
} else if (res[0] && res?.length) {
459+
setContractName("_Users");
460+
currUserId = res[0].objectId;
461+
setSignerUserId(currUserId);
462+
const tourstatus = res[0].TourStatus && res[0].TourStatus;
463+
if (tourstatus && tourstatus.length > 0) {
464+
setTourStatus(tourstatus);
465+
const checkTourRequestSign = tourstatus.filter(
466+
(data) => data.requestSign
467+
);
468+
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
469+
setRequestSignTour(checkTourRequestSign[0].requestSign);
470+
}
471+
}
472+
} else if (res?.length === 0) {
473+
const res = await contactBook(currUserId);
470474
if (res === "Error: Something went wrong!") {
471475
setHandleError("Error: Something went wrong!");
472-
} else if (res[0] && res?.length) {
473-
setContractName("_Users");
474-
currUserId = res[0].objectId;
475-
setSignerUserId(currUserId);
476+
} else if (res[0] && res.length) {
477+
setContractName("_Contactbook");
478+
const objectId = res[0].objectId;
479+
setSignerUserId(objectId);
476480
const tourstatus = res[0].TourStatus && res[0].TourStatus;
477481
if (tourstatus && tourstatus.length > 0) {
478482
setTourStatus(tourstatus);
@@ -483,33 +487,12 @@ function PdfRequestFiles() {
483487
setRequestSignTour(checkTourRequestSign[0].requestSign);
484488
}
485489
}
486-
} else if (res?.length === 0) {
487-
const res = await contactBook(currUserId);
488-
if (res === "Error: Something went wrong!") {
489-
setHandleError("Error: Something went wrong!");
490-
} else if (res[0] && res.length) {
491-
setContractName("_Contactbook");
492-
const objectId = res[0].objectId;
493-
setSignerUserId(objectId);
494-
const tourstatus = res[0].TourStatus && res[0].TourStatus;
495-
if (tourstatus && tourstatus.length > 0) {
496-
setTourStatus(tourstatus);
497-
const checkTourRequestSign = tourstatus.filter(
498-
(data) => data.requestSign
499-
);
500-
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
501-
setRequestSignTour(checkTourRequestSign[0].requestSign);
502-
}
503-
}
504-
} else if (res.length === 0) {
505-
setHandleError("Error: User does not exist!");
506-
}
490+
} else if (res.length === 0) {
491+
setHandleError("Error: User does not exist!");
507492
}
508493
}
509-
setIsUiLoading(false);
510-
} else {
511-
alert("No data found!");
512494
}
495+
setIsUiLoading(false);
513496
} else if (
514497
documentData === "Error: Something went wrong!" ||
515498
(documentData.result && documentData.result.error)
@@ -824,7 +807,7 @@ function PdfRequestFiles() {
824807
"https://qikinnovation.ams3.digitaloceanspaces.com/logo.png";
825808
let url = `${localStorage.getItem(
826809
"baseUrl"
827-
)}functions/sendmailv3/`;
810+
)}functions/sendmailv3`;
828811
const headers = {
829812
"Content-Type": "application/json",
830813
"X-Parse-Application-Id":

apps/OpenSignServer/cloud/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PDF from './parsefunction/pdf/PDF.min.js';
1+
import PDF from './parsefunction/pdf/PDF.js';
22
import sendmailv3 from './parsefunction/sendMailv3.js';
33
import GoogleSign from './parsefunction/GoogleSign.js';
44
import ZohoDetails from './parsefunction/ZohoDetails.js';

0 commit comments

Comments
 (0)