diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js index 005cc4cb2..5b0dbf2a9 100644 --- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js +++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js @@ -368,8 +368,9 @@ function PdfRequestFiles() { return true; } }; + //function for embed signature or image url in pdf - async function embedImages() { + async function embedWidgetsData() { const validateSigning = checkSendInOrder(); if (validateSigning) { const checkUser = signerPos.filter( @@ -378,69 +379,122 @@ function PdfRequestFiles() { if (checkUser && checkUser.length > 0) { let unSignUrlData, checkboxExist, - isReadOnly, - minCountAlert = false, - checkboxKey; + requiredRadio, + showAlert = false, + widgetKey, + radioExist, + requiredCheckbox + ; for (let i = 0; i < checkUser[0].placeHolder.length; i++) { checkboxExist = checkUser[0].placeHolder[i].pos.some( (data) => data.type === "checkbox" ); - + radioExist = checkUser[0].placeHolder[i].pos.some( + (data) => data.type === "radio" + ); if (checkboxExist) { - isReadOnly = checkUser[0].placeHolder[i].pos.filter( - (position) => !position.options?.isReadOnly + requiredCheckbox = checkUser[0].placeHolder[i].pos.filter( + (position) => !position.options?.isReadOnly && position.type ==='checkbox' ); - if (isReadOnly && isReadOnly.length > 0) { - for (let i = 0; i < isReadOnly.length; i++) { + if (requiredCheckbox && requiredCheckbox.length > 0) { + for (let i = 0; i < requiredCheckbox.length; i++) { const minCount = - isReadOnly[i].options?.validation?.minRequiredCount; + requiredCheckbox[i].options?.validation?.minRequiredCount; const parseMin = minCount && parseInt(minCount); const maxCount = - isReadOnly[i].options?.validation?.maxRequiredCount; + requiredCheckbox[i].options?.validation?.maxRequiredCount; const parseMax = maxCount && parseInt(maxCount); - const response = isReadOnly[i].options?.response?.length; - const defaultValue = isReadOnly[i].options?.defaultValue?.length; + const response = requiredCheckbox[i].options?.response?.length; + const defaultValue = requiredCheckbox[i].options?.defaultValue?.length; if (parseMin === 0 && parseMax === 0) { - if (!minCountAlert) { - minCountAlert = false; + if (!showAlert) { + showAlert = false; } } else if (parseMin === 0 && parseMax > 0) { - if (!minCountAlert) { - minCountAlert = false; + if (!showAlert) { + showAlert = false; } } else if (!response) { if (!defaultValue) { - if (!minCountAlert) { - minCountAlert = true; - checkboxKey = isReadOnly[i].key; + if (!showAlert) { + showAlert = true; + widgetKey = requiredCheckbox[i].key; setminRequiredCount(parseMin); } } } else if (parseMin > 0 && parseMin > response) { - if (!minCountAlert) { - minCountAlert = true; - checkboxKey = isReadOnly[i].key; + if (!showAlert) { + showAlert = true; + widgetKey = requiredCheckbox[i].key; setminRequiredCount(parseMin); } } } } - } else { - unSignUrlData = checkUser[0].placeHolder[i].pos.filter( - (pos) => !pos?.SignUrl && !pos.options.response + } else if(radioExist) { + requiredRadio = checkUser[0].placeHolder[i].pos.filter( + (position) => !position.options?.isReadOnly && position.type ==='radio' + ); + + if (requiredRadio && requiredRadio.length > 0) { + let checkSigned ; + for(let i=0; i < requiredRadio.length; i++){ + checkSigned = requiredRadio[i]?.options.response + if(!checkSigned){ + let checkDefaultSigned = requiredRadio[i]?.options.defaultValue + if(!checkDefaultSigned){ + if (!showAlert) { + showAlert = true; + widgetKey = requiredRadio[i].key; + } + } + } + } + } + } else{ + + const requiredWidgets = checkUser[0].placeHolder[i].pos.filter( + (position) => !position.options?.isReadOnly ); + if(requiredWidgets && requiredCheckbox.length >0){ + unSignUrlData = checkUser[0].placeHolder[i].pos.filter( + (pos) => !pos?.SignUrl && !pos.options.response + ); + let checkSigned ; + for(let i=0; i < requiredWidgets.length; i++){ + checkSigned = requiredWidgets[i]?.options?.response + if(!checkSigned){ + const checkSignUrl = requiredWidgets[i]?.pos?.SignUrl + + let checkDefaultSigned = requiredWidgets[i]?.options?.defaultValue + if(!checkSignUrl){ + if(!checkDefaultSigned){ + if (!showAlert) { + showAlert = true; + widgetKey = requiredWidgets[i].key; + } + } + } + + } + } + } } } - if (checkboxExist && isReadOnly && minCountAlert) { - setUnSignedWidgetId(checkboxKey); + if (checkboxExist && requiredCheckbox && showAlert) { + setUnSignedWidgetId(widgetKey); setWidgetsTour(true); - } else if (!checkboxExist && unSignUrlData && unSignUrlData.length > 0) { - setUnSignedWidgetId(unSignUrlData[0].key); + }else if(radioExist && showAlert ){ + setUnSignedWidgetId(widgetKey); setWidgetsTour(true); } + else if (showAlert) { + setUnSignedWidgetId(widgetKey); + setWidgetsTour(true); + } else { setIsUiLoading(true); const pngUrl = checkUser[0].placeHolder; @@ -555,6 +609,7 @@ function PdfRequestFiles() { flag, containerWH ); + //function for call to embed signature in pdf and get digital signature pdf try { const res = await signPdfFun( @@ -1188,7 +1243,7 @@ function PdfRequestFiles() { signerPos={signerPos} isSigned={isSigned} isCompleted={isCompleted} - embedImages={embedImages} + embedWidgetsData={embedWidgetsData} isShowHeader={true} setIsDecline={setIsDecline} decline={true} diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js index 9e3f40565..40c0b161c 100644 --- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js +++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js @@ -98,7 +98,7 @@ function SignYourSelf() { const [isDontShow, setIsDontShow] = useState(false); const divRef = useRef(null); const nodeRef = useRef(null); - const [{ isOver }, drop] = useDrop({ + const [, drop] = useDrop({ accept: "BOX", drop: (item, monitor) => addPositionOfSignature(item, monitor), collect: (monitor) => ({ @@ -180,7 +180,7 @@ function SignYourSelf() { if (documentData && documentData.length > 0) { setPdfDetails(documentData); - setIsUiLoading(false); + const isCompleted = documentData[0].IsCompleted && documentData[0].IsCompleted; if (isCompleted) { @@ -195,6 +195,12 @@ function SignYourSelf() { }; if (showComplete) { setShowAlreadySignDoc(alreadySign); + }else{ + setIsUiLoading(false); + setIsSignPad(false); + setIsEmail(true); + setXyPostion([]); + setSignBtnPosition([]); } } } else if ( @@ -561,13 +567,12 @@ function SignYourSelf() { }; //function for send placeholder's co-ordinate(x,y) position embed signature url or stamp url - async function embedImages() { + async function embedWidgetsData() { let checkSigned = 0; let allXyPos = 0; for (let i = 0; i < xyPostion.length; i++) { - // const posSignUrlData = xyPostion[i].pos.filter((pos) => pos.SignUrl); - const posWidgetData = xyPostion[i].pos.filter( + const posWidgetData = xyPostion[i].pos.filter( (pos) => pos.options.response ); @@ -620,13 +625,10 @@ function SignYourSelf() { flag, containerWH ); - +// console.log(pdfBytes) //function for call to embed signature in pdf and get digital signature pdf - signPdfFun(pdfBytes, documentId); - setIsSignPad(false); - setIsEmail(true); - setXyPostion([]); - setSignBtnPosition([]); + await signPdfFun(pdfBytes, documentId); + } } @@ -1150,7 +1152,7 @@ function SignYourSelf() { changePage={changePage} pdfUrl={pdfUrl} documentStatus={documentStatus} - embedImages={embedImages} + embedWidgetsData={embedWidgetsData} pdfDetails={pdfDetails} isShowHeader={true} currentSigner={true} @@ -1202,7 +1204,7 @@ function SignYourSelf() { {/*if document is not completed then render signature and stamp button in the right side */} {/*else document is completed then render signed by signer name in the right side */}