🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix: conflict resolve
RaktimaNXG2f7a1d67b6ad
diff --cc apps/OpenSign/src/pages/PdfRequestFiles.jsindex 75b918126,2976359c7..0573fc649--- a/apps/OpenSign/src/pages/PdfRequestFiles.js+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js@@@ -337,177 -327,201 +349,176 @@@ function PdfRequestFiles()}}}- if (documentData.length > 0) {- const checkDocIdExist =- documentData[0].AuditTrail &&- documentData[0].AuditTrail.length > 0 &&- documentData[0].AuditTrail.filter(- (data) => data.Activity === "Signed"- );+ const audittrailData =+ documentData[0].AuditTrail &&+ documentData[0].AuditTrail.length > 0 &&+ documentData[0].AuditTrail.filter((data) => data.Activity === "Signed");- const checkAlreadySign =- documentData[0].AuditTrail &&- documentData[0].AuditTrail.length > 0 &&- documentData[0].AuditTrail.filter(- (data) =>- data.UserPtr.objectId === currUserId && data.Activity === "Signed"- );+ const checkAlreadySign =+ documentData[0].AuditTrail &&+ documentData[0].AuditTrail.length > 0 &&+ documentData[0].AuditTrail.filter(+ (data) =>+ data.UserPtr.objectId === currUserId && data.Activity === "Signed"+ );+ if (+ checkAlreadySign &&+ checkAlreadySign[0] &&+ checkAlreadySign.length > 0+ ) {+ setAlreadySign(true);+ } else {+ const obj = documentData?.[0];+ setSendInOrder(obj?.SendinOrder || false);if (- checkAlreadySign &&- checkAlreadySign[0] &&- checkAlreadySign.length > 0+ obj &&+ obj.Signers &&+ obj.Signers.length > 0 &&+ obj.Placeholders &&+ obj.Placeholders.length > 0) {- setAlreadySign(true);- } else {- const obj = documentData?.[0];- setSendInOrder(obj?.SendinOrder || false);- if (- obj &&- obj.Signers &&- obj.Signers.length > 0 &&- obj.Placeholders &&- obj.Placeholders.length > 0- ) {- const params = {- event: "viewed",- contactId: currUserId,- body: {- objectId: documentData?.[0].objectId,- file: documentData?.[0]?.SignedUrl || documentData?.[0]?.URL,- name: documentData?.[0].Name,- note: documentData?.[0].Note || "",- description: documentData?.[0].Description || "",- signers: documentData?.[0].Signers?.map((x) => ({- name: x?.Name,- email: x?.Email,- phone: x?.Phone- })),- viewedBy: jsonSender.email,- viewedAt: new Date(),- createdAt: documentData?.[0].createdAt- }- };+ const params = {+ event: "viewed",+ contactId: currUserId,+ body: {+ objectId: documentData?.[0].objectId,+ file: documentData?.[0]?.SignedUrl || documentData?.[0]?.URL,+ name: documentData?.[0].Name,+ note: documentData?.[0].Note || "",+ description: documentData?.[0].Description || "",+ signers: documentData?.[0].Signers?.map((x) => ({+ name: x?.Name,+ email: x?.Email,+ phone: x?.Phone+ })),+ viewedBy: jsonSender.email,+ viewedAt: new Date(),+ createdAt: documentData?.[0].createdAt+ }+ };- try {- await axios.post(- `${localStorage.getItem("baseUrl")}functions/callwebhook`,- params,- {- headers: {- "Content-Type": "application/json",- "X-Parse-Application-Id":- localStorage.getItem("parseAppId"),- sessiontoken: localStorage.getItem("accesstoken")- }+ try {+ await axios.post(+ `${localStorage.getItem("baseUrl")}functions/callwebhook`,+ params,+ {+ headers: {+ "Content-Type": "application/json",+ "X-Parse-Application-Id": localStorage.getItem("parseAppId"),+ sessiontoken: localStorage.getItem("accesstoken")}- );- } catch (err) {- console.log("Err ", err);- }+ }+ );+ } catch (err) {+ console.log("Err ", err);}}+ }- let signers = [];- let unSignedSigner = [];+ let signers = [];+ let unSignedSigner = [];- //check document is signed or not- if (checkDocIdExist && checkDocIdExist.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 = [];+ for (const placeholder of documentData[0].Placeholders) {+ //`emailExist` variable to handle condition for quick send flow and show unsigned signers list+ const emailExist = placeholder?.email;+ if (emailExist) {+ placeholdersOrSigners.push(placeholder);+ } else {+ const getSignerData = documentData[0].Signers.find(+ (data) => data.objectId === placeholder?.signerObjId+ );+ placeholdersOrSigners.push(getSignerData);+ }+ }+ //condition to check already signed document by someone+ if (audittrailData && audittrailData.length > 0) {+ setIsDocId(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+ for (const item of placeholdersOrSigners) {+ const checkEmail = item?.email;+ //if email exist then compare user signed by using email else signers objectId+ const emailOrId = checkEmail ? item.email : item.objectId;+ //`isSignedSignature` variable to handle break loop whenever it get true+ let isSignedSignature = false;+ //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 = checkEmail+ ? doc?.UserPtr.Email+ : doc?.UserPtr.objectId;- if (signerId === signedExist) {- signers.push({ ...signerRes[i], ...signerRes[i] });- isSignedSignature = true;- break;- }- // if does not match then add unsigned data in unSignedSigner array- }- if (!isSignedSignature) {- unSignedSigner.push({ ...signerRes[i], ...signerRes[i] });+ if (emailOrId === signedExist) {+ signers.push({ ...item });+ isSignedSignature = true;+ break;}}- setSignedSigners(signers);- setUnSignedSigners(unSignedSigner);-- setSignerPos(documentData[0].Placeholders);- } else {- let unsigned = [];- for (let i = 0; i < documentData.length; i++) {- unsigned.push(documentData[i].Signers);+ if (!isSignedSignature) {+ unSignedSigner.push({ ...item });}- setUnSignedSigners(unsigned[0]);- setSignerPos(documentData[0].Placeholders);}- setPdfDetails(documentData);- // Check if the current signer is not a last signer and handle the complete message.- if (isNextUser) {- const getSignedAuditTrail = documentData[0].AuditTrail.filter(- (data) => data.Activity === "Signed"- );- const isLastSigner =- getSignedAuditTrail?.length === documentData?.[0]?.Signers?.length;- if (!isLastSigner) {- setIsCompleted({- isModal: true,- message:- "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."- });- } else {- setIsCelebration(true);- setTimeout(() => {- setIsCelebration(false);- }, 5000);+ 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+ setUnSignedSigners(placeholdersOrSigners);+ setSignerPos(documentData[0].Placeholders);+ }+ setPdfDetails(documentData);+ //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+ //then stop to display tour message+ if (+ (checkAlreadySign &&+ checkAlreadySign[0] &&+ checkAlreadySign.length > 0) ||+ !currUserId ||+ declined ||+ currDate > expireUpdateDate+ ) {+ 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+ const localuser = localStorage.getItem(+ `Parse/${appInfo.appId}/currentUser`+ );+ const currentUser = JSON.parse(JSON.stringify(localuser));+ const currentUserEmail = currentUser.email;+ const res = await contractUsers(currentUserEmail);+ if (res === "Error: Something went wrong!") {+ setHandleError("Error: Something went wrong!");+ } else if (res[0] && res?.length) {+ setContractName("_Users");+ currUserId = res[0].objectId;+ setSignerUserId(currUserId);+ const tourData = res[0].TourStatus && res[0].TourStatus;+ if (tourData && tourData.length > 0) {+ setTourStatus(tourData);+ setRequestSignTour(tourData[0]?.requestSign || false);}- }- //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- //then stop to display tour message- if (- (checkAlreadySign &&- checkAlreadySign[0] &&- checkAlreadySign.length > 0) ||- !currUserId ||- declined ||- currDate > expireUpdateDate- ) {- setRequestSignTour(false);- } 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- const localuser = localStorage.getItem(- `Parse/${appInfo.appId}/currentUser`- );- const currentUser = JSON.parse(JSON.stringify(localuser));- const currentUserEmail = currentUser?.email;- const res = await contractUsers(currentUserEmail);+ } 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("_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);- }- }- } 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);- }- }- } else if (res.length === 0) {- setHandleError("Error: User does not exist!");+ } else if (res[0] && res.length) {+ setContractName("_Contactbook");+ const objectId = res[0].objectId;+ setSignerUserId(objectId);+ 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!");}}- setIsUiLoading(false);- } else {- alert("No data found!");}+ setIsUiLoading(false);} else if (documentData === "Error: Something went wrong!" ||(documentData.result && documentData.result.error)