diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js index 6fc5fa190..d082df880 100644 --- a/apps/OpenSign/src/pages/PlaceHolderSign.js +++ b/apps/OpenSign/src/pages/PlaceHolderSign.js @@ -830,11 +830,11 @@ function PlaceHolderSign() { return pdfDetails[0].URL; } }; - const alertSendEmail = async () => { const filterPrefill = signerPos?.filter((data) => data.Role !== "prefill"); const getPrefill = signerPos?.filter((data) => data.Role === "prefill"); let isLabel = false; + //condition is used to check text widget data is empty or have response if (getPrefill && getPrefill.length > 0) { const prefillPlaceholder = getPrefill[0].placeHolder; if (prefillPlaceholder) { @@ -845,6 +845,29 @@ function PlaceHolderSign() { }); } } + let notExistSignature = false; // variable is used to check a signature widget exit or not then execute other code + //for loop is used to check signature widget exist or not + for (let item of filterPrefill) { + let signatureExist = false; // Reset for each iteration + for (let x of item.placeHolder) { + if (!signatureExist) { + const typeExist = x.pos.some((data) => data?.type); + if (typeExist) { + signatureExist = x.pos.some((data) => data?.type === "signature"); + } else { + signatureExist = x.pos.some((data) => !data.isStamp); + } + } + } + if (!signatureExist) { + notExistSignature = true; + const alert = { + mssg: "sure", + alert: true + }; + setIsSendAlert(alert); + } + } if (getPrefill && isLabel) { const alert = { @@ -852,23 +875,26 @@ function PlaceHolderSign() { alert: true }; setIsSendAlert(alert); - } else if (filterPrefill.length === signersdata.length) { - const IsSignerNotExist = filterPrefill?.filter((x) => !x.signerObjId); - if (IsSignerNotExist && IsSignerNotExist?.length > 0) { - setSignerExistModal(true); - setSelectWidgetId(IsSignerNotExist[0]?.placeHolder?.[0]?.pos?.[0]?.key); + } else if (!notExistSignature) { + if (filterPrefill.length === signersdata.length) { + const IsSignerNotExist = filterPrefill?.filter((x) => !x.signerObjId); + if (IsSignerNotExist && IsSignerNotExist?.length > 0) { + setSignerExistModal(true); + setSelectWidgetId( + IsSignerNotExist[0]?.placeHolder?.[0]?.pos?.[0]?.key + ); + } else { + saveDocumentDetails(); + } } else { - saveDocumentDetails(); + const alert = { + mssg: "sure", + alert: true + }; + setIsSendAlert(alert); } - } else { - const alert = { - mssg: "sure", - alert: true - }; - setIsSendAlert(alert); } }; - //function to use save placeholder details in contracts_document const saveDocumentDetails = async () => { setIsUiLoading(true); diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.js index 7fe144910..63fb8e8b7 100644 --- a/apps/OpenSign/src/pages/SignyourselfPdf.js +++ b/apps/OpenSign/src/pages/SignyourselfPdf.js @@ -480,13 +480,13 @@ function SignYourSelf() { Width: widgetTypeExist ? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth : dragTypeValue === "initials" - ? defaultWidthHeight(dragTypeValue).width - : "", + ? defaultWidthHeight(dragTypeValue).width + : "", Height: widgetTypeExist ? calculateInitialWidthHeight(dragTypeValue, widgetValue).getHeight : dragTypeValue === "initials" - ? defaultWidthHeight(dragTypeValue).height - : "", + ? defaultWidthHeight(dragTypeValue).height + : "", options: addWidgetOptions(dragTypeValue) }; @@ -603,7 +603,8 @@ function SignYourSelf() { }; //function for send placeholder's co-ordinate(x,y) position embed signature url or stamp url async function embedWidgetsData() { - let showAlert = false; + let showAlert = false, + isSignatureExist = false; try { for (let i = 0; i < xyPostion?.length; i++) { const requiredWidgets = xyPostion[i].pos.filter( @@ -627,17 +628,25 @@ function SignYourSelf() { } } } + //condition to check exist signature widget or not + if (!isSignatureExist) { + isSignatureExist = xyPostion[i].pos.some( + (data) => data?.type === "signature" + ); + } } - if (xyPostion.length === 0) { + if (xyPostion.length === 0 || !isSignatureExist) { setIsAlert({ isShow: true, - alertMessage: "Please complete your signature!" + alertMessage: + "Please ensure there's at least one signature widget added" }); return; } else if (showAlert) { setIsAlert({ isShow: true, - alertMessage: "Please complete your signature!" + alertMessage: + "Please ensure all field is accurately filled and meets all requirements." }); return; } else { @@ -713,13 +722,13 @@ function SignYourSelf() { // for adding it in completion certificate let getSignature; for (let item of xyPostion) { - const typeExist = item.pos.some((data) => data?.type); - if (typeExist) { - getSignature = item.pos.find((data) => data?.type === "signature"); - break; - } else { - getSignature = item.pos.find((data) => !data.isStamp); - break; + if (!getSignature) { + const typeExist = item.pos.some((data) => data?.type); + if (typeExist) { + getSignature = item.pos.find((data) => data?.type === "signature"); + } else { + getSignature = item.pos.find((data) => !data.isStamp); + } } } let base64Sign = getSignature.SignUrl;