Skip to content

Commit 2900464

Browse files
fix: display the list of unsigned signers in the 'Yet to Sign' panel using the QuickSend flow.
1 parent 302f38d commit 2900464

File tree

2 files changed

+79
-56
lines changed

2 files changed

+79
-56
lines changed

apps/OpenSign/src/components/pdf/RenderPdf.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,15 @@ function RenderPdf({
204204
};
205205
//function for render placeholder block over pdf document
206206
const checkSignedSignes = (data) => {
207-
const checkSign = signedSigners.filter(
208-
(sign) => sign.objectId === data.signerObjId
209-
);
207+
let checkSign = [];
208+
//condition to handle quick send flow and using normal request sign flow
209+
if (signedSigners[0]?.Id) {
210+
checkSign = signedSigners.filter((sign) => sign.Id === data.Id);
211+
} else {
212+
checkSign = signedSigners.filter(
213+
(sign) => sign.objectId === data.signerObjId
214+
);
215+
}
210216
if (data.signerObjId === signerObjectId) {
211217
setCurrentSigner(true);
212218
}

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 70 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
contactBook,
3333
handleDownloadPdf,
3434
handleToPrint,
35-
handleDownloadCertificate
35+
handleDownloadCertificate,
36+
darkenColor
3637
} from "../constant/Utils";
3738
import Loader from "../primitives/LoaderWithMsg";
3839
import HandleError from "../primitives/HandleError";
@@ -74,7 +75,7 @@ function PdfRequestFiles() {
7475
const [selectWidgetId, setSelectWidgetId] = useState("");
7576
const [otpLoader, setOtpLoader] = useState(false);
7677
const [isCelebration, setIsCelebration] = useState(false);
77-
const [requestSignTour, setRequestSignTour] = useState(true);
78+
const [requestSignTour, setRequestSignTour] = useState(false);
7879
const [tourStatus, setTourStatus] = useState([]);
7980
const [isLoading, setIsLoading] = useState({
8081
isLoad: true,
@@ -296,6 +297,10 @@ function PdfRequestFiles() {
296297
setExpiredDate(expireDateFormat);
297298
} // Check if the current signer is not a last signer and handle the complete message.
298299
else if (isNextUser) {
300+
setIsCelebration(true);
301+
setTimeout(() => {
302+
setIsCelebration(false);
303+
}, 5000);
299304
setIsCompleted({
300305
isModal: true,
301306
message:
@@ -330,7 +335,7 @@ function PdfRequestFiles() {
330335
}
331336
}
332337
}
333-
const checkDocIdExist =
338+
const audittrailData =
334339
documentData[0].AuditTrail &&
335340
documentData[0].AuditTrail.length > 0 &&
336341
documentData[0].AuditTrail.filter((data) => data.Activity === "Signed");
@@ -398,41 +403,49 @@ function PdfRequestFiles() {
398403

399404
let signers = [];
400405
let unSignedSigner = [];
406+
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
407+
const emailExist = documentData[0].Placeholders[0]?.email;
401408

402-
//check document is signed or not
403-
if (checkDocIdExist && checkDocIdExist.length > 0) {
409+
//condition to check already signed document by someone
410+
if (audittrailData && audittrailData.length > 0) {
404411
setIsDocId(true);
405-
const signerRes = documentData[0].Signers;
406-
//comparison auditTrail user details with signers user details
407-
for (let i = 0; i < signerRes.length; i++) {
408-
const signerId = signerRes[i].objectId;
412+
const placeholdersOrSigners = emailExist
413+
? documentData[0].Placeholders
414+
: documentData[0].Signers;
409415

416+
for (const item of placeholdersOrSigners) {
417+
//if email exist then compare user signed by using email else signers objectId
418+
const emailOrId = emailExist ? item.email : item.objectId;
419+
//`isSignedSignature` variable to handle break loop whenever it get true
410420
let isSignedSignature = false;
411-
for (let j = 0; j < checkDocIdExist.length; j++) {
412-
const signedExist =
413-
checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId;
414-
//checking signerObjId and auditTrail User objId
415-
// if match then add signed data in signer array and break loop
421+
//checking the signer who signed the document by using audit trail details.
422+
//and save signedSigners and unsignedSigners details
423+
for (const doc of audittrailData) {
424+
const signedExist = emailExist
425+
? doc?.UserPtr.Email
426+
: doc?.UserPtr.objectId;
416427

417-
if (signerId === signedExist) {
418-
signers.push({ ...signerRes[i], ...signerRes[i] });
428+
if (emailOrId === signedExist) {
429+
signers.push({ ...item });
419430
isSignedSignature = true;
420431
break;
421432
}
422-
// if does not match then add unsigned data in unSignedSigner array
423433
}
424434
if (!isSignedSignature) {
425-
unSignedSigner.push({ ...signerRes[i], ...signerRes[i] });
435+
unSignedSigner.push({ ...item });
426436
}
427437
}
428438
setSignedSigners(signers);
429439
setUnSignedSigners(unSignedSigner);
430440
setSignerPos(documentData[0].Placeholders);
431441
} else {
442+
//else condition is show there are no details in audit trail then direct push all signers details
443+
//in unsignedsigners array
432444
let unsigned = [];
433-
for (let i = 0; i < documentData.length; i++) {
434-
unsigned.push(documentData[i].Signers);
435-
}
445+
const placeholdersOrSigners = emailExist
446+
? documentData[0].Placeholders
447+
: documentData[0].Signers;
448+
unsigned.push(placeholdersOrSigners);
436449
setUnSignedSigners(unsigned[0]);
437450
setSignerPos(documentData[0].Placeholders);
438451
}
@@ -447,7 +460,7 @@ function PdfRequestFiles() {
447460
declined ||
448461
currDate > expireUpdateDate
449462
) {
450-
setRequestSignTour(false);
463+
setRequestSignTour(true);
451464
} else {
452465
//else condition to check current user exist in contracts_Users class and check tour message status
453466
//if not then check user exist in contracts_Contactbook class and check tour message status
@@ -463,33 +476,25 @@ function PdfRequestFiles() {
463476
setContractName("_Users");
464477
currUserId = res[0].objectId;
465478
setSignerUserId(currUserId);
466-
const tourstatus = res[0].TourStatus && res[0].TourStatus;
467-
if (tourstatus && tourstatus.length > 0) {
468-
setTourStatus(tourstatus);
469-
const checkTourRequestSign = tourstatus.filter(
470-
(data) => data.requestSign
471-
);
472-
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
473-
setRequestSignTour(checkTourRequestSign[0].requestSign);
474-
}
479+
const tourData = res[0].TourStatus && res[0].TourStatus;
480+
if (tourData && tourData.length > 0) {
481+
setTourStatus(tourData);
482+
setRequestSignTour(tourData[0]?.requestSign || false);
475483
}
476484
} else if (res?.length === 0) {
477485
const res = await contactBook(currUserId);
486+
478487
if (res === "Error: Something went wrong!") {
479488
setHandleError("Error: Something went wrong!");
480489
} else if (res[0] && res.length) {
481490
setContractName("_Contactbook");
482491
const objectId = res[0].objectId;
483492
setSignerUserId(objectId);
484-
const tourstatus = res[0].TourStatus && res[0].TourStatus;
485-
if (tourstatus && tourstatus.length > 0) {
486-
setTourStatus(tourstatus);
487-
const checkTourRequestSign = tourstatus.filter(
488-
(data) => data.requestSign
489-
);
490-
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
491-
setRequestSignTour(checkTourRequestSign[0].requestSign);
492-
}
493+
const tourData = res[0].TourStatus && res[0].TourStatus;
494+
495+
if (tourData && tourData.length > 0) {
496+
setTourStatus(tourData);
497+
setRequestSignTour(tourData[0]?.requestSign || false);
493498
}
494499
} else if (res.length === 0) {
495500
setHandleError("Error: User does not exist!");
@@ -552,7 +557,6 @@ function PdfRequestFiles() {
552557
setIsLoading(loadObj);
553558
});
554559
};
555-
556560
//function for embed signature or image url in pdf
557561
async function embedWidgetsData() {
558562
try {
@@ -1109,9 +1113,19 @@ function PdfRequestFiles() {
11091113
};
11101114

11111115
const checkSignerBackColor = (obj) => {
1112-
const data = signerPos.filter((data) => data.signerObjId === obj.objectId);
1116+
let data = "";
1117+
if (obj?.Id) {
1118+
data = signerPos.filter((data) => data.Id === obj.Id);
1119+
} else {
1120+
data = signerPos.filter((data) => data.signerObjId === obj.objectId);
1121+
}
11131122
return data && data.length > 0 && data[0].blockColor;
11141123
};
1124+
const checkUserNameColor = (obj) => {
1125+
const getBackColor = checkSignerBackColor(obj);
1126+
const color = darkenColor(getBackColor, 0.4);
1127+
return color;
1128+
};
11151129

11161130
//function for set decline true on press decline button
11171131
const declineDoc = async () => {
@@ -1210,7 +1224,7 @@ function PdfRequestFiles() {
12101224
};
12111225
//function to close tour and save tour status
12121226
const closeRequestSignTour = async () => {
1213-
setRequestSignTour(false);
1227+
setRequestSignTour(true);
12141228
if (isDontShow) {
12151229
let updatedTourStatus = [];
12161230
if (tourStatus.length > 0) {
@@ -1332,7 +1346,6 @@ function PdfRequestFiles() {
13321346
/>
13331347
);
13341348
};
1335-
13361349
return (
13371350
<DndProvider backend={HTML5Backend}>
13381351
<Title title={"Request Sign"} />
@@ -1401,7 +1414,7 @@ function PdfRequestFiles() {
14011414
}}
14021415
ref={divRef}
14031416
>
1404-
{requestSignTour && requestSignTourFunction()}
1417+
{!requestSignTour && requestSignTourFunction()}
14051418
<ModalUi
14061419
headerColor={"#dc3545"}
14071420
isOpen={isAlert.isShow}
@@ -1781,7 +1794,7 @@ function PdfRequestFiles() {
17811794
<div
17821795
className="signerStyle"
17831796
style={{
1784-
background: "#abd1d0",
1797+
background: checkUserNameColor(obj),
17851798
width: 30,
17861799
height: 30,
17871800
display: "flex",
@@ -1800,7 +1813,7 @@ function PdfRequestFiles() {
18001813
textTransform: "uppercase"
18011814
}}
18021815
>
1803-
{getFirstLetter(obj.Name)}
1816+
{getFirstLetter(obj?.Name || obj?.Role)}
18041817
</span>
18051818
</div>
18061819
<div
@@ -1809,9 +1822,11 @@ function PdfRequestFiles() {
18091822
flexDirection: "column"
18101823
}}
18111824
>
1812-
<span className="userName">{obj.Name}</span>
1825+
<span className="userName">
1826+
{obj?.Name || obj?.Role}
1827+
</span>
18131828
<span className="useEmail">
1814-
{obj.Email}
1829+
{obj?.Email || obj?.email}
18151830
</span>
18161831
</div>
18171832
</div>
@@ -1850,7 +1865,7 @@ function PdfRequestFiles() {
18501865
<div
18511866
className="signerStyle"
18521867
style={{
1853-
background: "#abd1d0",
1868+
background: checkUserNameColor(obj),
18541869
width: 30,
18551870
height: 30,
18561871
display: "flex",
@@ -1869,7 +1884,7 @@ function PdfRequestFiles() {
18691884
textTransform: "uppercase"
18701885
}}
18711886
>
1872-
{getFirstLetter(obj.Name)}
1887+
{getFirstLetter(obj?.Name || obj?.email)}
18731888
</span>
18741889
</div>
18751890
<div
@@ -1878,9 +1893,11 @@ function PdfRequestFiles() {
18781893
flexDirection: "column"
18791894
}}
18801895
>
1881-
<span className="userName">{obj.Name}</span>
1896+
<span className="userName">
1897+
{obj?.Name || obj?.Role}
1898+
</span>
18821899
<span className="useEmail">
1883-
{obj.Email}
1900+
{obj?.Email || obj?.email}
18841901
</span>
18851902
</div>
18861903
<hr />

0 commit comments

Comments
 (0)