fix: display the list of unsigned signers in the 'Yet to Sign' panel using the QuickSend flow.

This commit is contained in:
RaktimaNXG
2024-06-07 14:20:36 +05:30
parent 302f38d472
commit 2900464272
2 changed files with 79 additions and 56 deletions
@@ -204,9 +204,15 @@ function RenderPdf({
};
//function for render placeholder block over pdf document
const checkSignedSignes = (data) => {
const checkSign = signedSigners.filter(
(sign) => sign.objectId === data.signerObjId
);
let checkSign = [];
//condition to handle quick send flow and using normal request sign flow
if (signedSigners[0]?.Id) {
checkSign = signedSigners.filter((sign) => sign.Id === data.Id);
} else {
checkSign = signedSigners.filter(
(sign) => sign.objectId === data.signerObjId
);
}
if (data.signerObjId === signerObjectId) {
setCurrentSigner(true);
}
+70 -53
View File
@@ -32,7 +32,8 @@ import {
contactBook,
handleDownloadPdf,
handleToPrint,
handleDownloadCertificate
handleDownloadCertificate,
darkenColor
} from "../constant/Utils";
import Loader from "../primitives/LoaderWithMsg";
import HandleError from "../primitives/HandleError";
@@ -74,7 +75,7 @@ function PdfRequestFiles() {
const [selectWidgetId, setSelectWidgetId] = useState("");
const [otpLoader, setOtpLoader] = useState(false);
const [isCelebration, setIsCelebration] = useState(false);
const [requestSignTour, setRequestSignTour] = useState(true);
const [requestSignTour, setRequestSignTour] = useState(false);
const [tourStatus, setTourStatus] = useState([]);
const [isLoading, setIsLoading] = useState({
isLoad: true,
@@ -296,6 +297,10 @@ function PdfRequestFiles() {
setExpiredDate(expireDateFormat);
} // Check if the current signer is not a last signer and handle the complete message.
else if (isNextUser) {
setIsCelebration(true);
setTimeout(() => {
setIsCelebration(false);
}, 5000);
setIsCompleted({
isModal: true,
message:
@@ -330,7 +335,7 @@ function PdfRequestFiles() {
}
}
}
const checkDocIdExist =
const audittrailData =
documentData[0].AuditTrail &&
documentData[0].AuditTrail.length > 0 &&
documentData[0].AuditTrail.filter((data) => data.Activity === "Signed");
@@ -398,41 +403,49 @@ function PdfRequestFiles() {
let signers = [];
let unSignedSigner = [];
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
const emailExist = documentData[0].Placeholders[0]?.email;
//check document is signed or not
if (checkDocIdExist && checkDocIdExist.length > 0) {
//condition to check already signed document by someone
if (audittrailData && audittrailData.length > 0) {
setIsDocId(true);
const signerRes = documentData[0].Signers;
//comparison auditTrail user details with signers user details
for (let i = 0; i < signerRes.length; i++) {
const signerId = signerRes[i].objectId;
const placeholdersOrSigners = emailExist
? documentData[0].Placeholders
: documentData[0].Signers;
for (const item of placeholdersOrSigners) {
//if email exist then compare user signed by using email else signers objectId
const emailOrId = emailExist ? item.email : item.objectId;
//`isSignedSignature` variable to handle break loop whenever it get true
let isSignedSignature = false;
for (let j = 0; j < checkDocIdExist.length; j++) {
const signedExist =
checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId;
//checking signerObjId and auditTrail User objId
// if match then add signed data in signer array and break loop
//checking the signer who signed the document by using audit trail details.
//and save signedSigners and unsignedSigners details
for (const doc of audittrailData) {
const signedExist = emailExist
? doc?.UserPtr.Email
: doc?.UserPtr.objectId;
if (signerId === signedExist) {
signers.push({ ...signerRes[i], ...signerRes[i] });
if (emailOrId === signedExist) {
signers.push({ ...item });
isSignedSignature = true;
break;
}
// if does not match then add unsigned data in unSignedSigner array
}
if (!isSignedSignature) {
unSignedSigner.push({ ...signerRes[i], ...signerRes[i] });
unSignedSigner.push({ ...item });
}
}
setSignedSigners(signers);
setUnSignedSigners(unSignedSigner);
setSignerPos(documentData[0].Placeholders);
} else {
//else condition is show there are no details in audit trail then direct push all signers details
//in unsignedsigners array
let unsigned = [];
for (let i = 0; i < documentData.length; i++) {
unsigned.push(documentData[i].Signers);
}
const placeholdersOrSigners = emailExist
? documentData[0].Placeholders
: documentData[0].Signers;
unsigned.push(placeholdersOrSigners);
setUnSignedSigners(unsigned[0]);
setSignerPos(documentData[0].Placeholders);
}
@@ -447,7 +460,7 @@ function PdfRequestFiles() {
declined ||
currDate > expireUpdateDate
) {
setRequestSignTour(false);
setRequestSignTour(true);
} else {
//else condition to check current user exist in contracts_Users class and check tour message status
//if not then check user exist in contracts_Contactbook class and check tour message status
@@ -463,33 +476,25 @@ function PdfRequestFiles() {
setContractName("_Users");
currUserId = res[0].objectId;
setSignerUserId(currUserId);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
if (tourstatus && tourstatus.length > 0) {
setTourStatus(tourstatus);
const checkTourRequestSign = tourstatus.filter(
(data) => data.requestSign
);
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
setRequestSignTour(checkTourRequestSign[0].requestSign);
}
const tourData = res[0].TourStatus && res[0].TourStatus;
if (tourData && tourData.length > 0) {
setTourStatus(tourData);
setRequestSignTour(tourData[0]?.requestSign || false);
}
} else if (res?.length === 0) {
const res = await contactBook(currUserId);
if (res === "Error: Something went wrong!") {
setHandleError("Error: Something went wrong!");
} else if (res[0] && res.length) {
setContractName("_Contactbook");
const objectId = res[0].objectId;
setSignerUserId(objectId);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
if (tourstatus && tourstatus.length > 0) {
setTourStatus(tourstatus);
const checkTourRequestSign = tourstatus.filter(
(data) => data.requestSign
);
if (checkTourRequestSign && checkTourRequestSign.length > 0) {
setRequestSignTour(checkTourRequestSign[0].requestSign);
}
const tourData = res[0].TourStatus && res[0].TourStatus;
if (tourData && tourData.length > 0) {
setTourStatus(tourData);
setRequestSignTour(tourData[0]?.requestSign || false);
}
} else if (res.length === 0) {
setHandleError("Error: User does not exist!");
@@ -552,7 +557,6 @@ function PdfRequestFiles() {
setIsLoading(loadObj);
});
};
//function for embed signature or image url in pdf
async function embedWidgetsData() {
try {
@@ -1109,9 +1113,19 @@ function PdfRequestFiles() {
};
const checkSignerBackColor = (obj) => {
const data = signerPos.filter((data) => data.signerObjId === obj.objectId);
let data = "";
if (obj?.Id) {
data = signerPos.filter((data) => data.Id === obj.Id);
} else {
data = signerPos.filter((data) => data.signerObjId === obj.objectId);
}
return data && data.length > 0 && data[0].blockColor;
};
const checkUserNameColor = (obj) => {
const getBackColor = checkSignerBackColor(obj);
const color = darkenColor(getBackColor, 0.4);
return color;
};
//function for set decline true on press decline button
const declineDoc = async () => {
@@ -1210,7 +1224,7 @@ function PdfRequestFiles() {
};
//function to close tour and save tour status
const closeRequestSignTour = async () => {
setRequestSignTour(false);
setRequestSignTour(true);
if (isDontShow) {
let updatedTourStatus = [];
if (tourStatus.length > 0) {
@@ -1332,7 +1346,6 @@ function PdfRequestFiles() {
/>
);
};
return (
<DndProvider backend={HTML5Backend}>
<Title title={"Request Sign"} />
@@ -1401,7 +1414,7 @@ function PdfRequestFiles() {
}}
ref={divRef}
>
{requestSignTour && requestSignTourFunction()}
{!requestSignTour && requestSignTourFunction()}
<ModalUi
headerColor={"#dc3545"}
isOpen={isAlert.isShow}
@@ -1781,7 +1794,7 @@ function PdfRequestFiles() {
<div
className="signerStyle"
style={{
background: "#abd1d0",
background: checkUserNameColor(obj),
width: 30,
height: 30,
display: "flex",
@@ -1800,7 +1813,7 @@ function PdfRequestFiles() {
textTransform: "uppercase"
}}
>
{getFirstLetter(obj.Name)}
{getFirstLetter(obj?.Name || obj?.Role)}
</span>
</div>
<div
@@ -1809,9 +1822,11 @@ function PdfRequestFiles() {
flexDirection: "column"
}}
>
<span className="userName">{obj.Name}</span>
<span className="userName">
{obj?.Name || obj?.Role}
</span>
<span className="useEmail">
{obj.Email}
{obj?.Email || obj?.email}
</span>
</div>
</div>
@@ -1850,7 +1865,7 @@ function PdfRequestFiles() {
<div
className="signerStyle"
style={{
background: "#abd1d0",
background: checkUserNameColor(obj),
width: 30,
height: 30,
display: "flex",
@@ -1869,7 +1884,7 @@ function PdfRequestFiles() {
textTransform: "uppercase"
}}
>
{getFirstLetter(obj.Name)}
{getFirstLetter(obj?.Name || obj?.email)}
</span>
</div>
<div
@@ -1878,9 +1893,11 @@ function PdfRequestFiles() {
flexDirection: "column"
}}
>
<span className="userName">{obj.Name}</span>
<span className="userName">
{obj?.Name || obj?.Role}
</span>
<span className="useEmail">
{obj.Email}
{obj?.Email || obj?.email}
</span>
</div>
<hr />