diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js index 6d2d33061..d741162d5 100644 --- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js +++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js @@ -192,7 +192,6 @@ function PdfRequestFiles() { //check document is signed or not if (checkDocIdExist && checkDocIdExist.length > 0) { - setAlreadySign(true); setIsDocId(true); const signerRes = res[0].Signers; //comparison auditTrail user details with signers user details diff --git a/microfrontends/SignDocuments/src/Component/component/header.js b/microfrontends/SignDocuments/src/Component/component/header.js index c68ad4ada..4d971cfb4 100644 --- a/microfrontends/SignDocuments/src/Component/component/header.js +++ b/microfrontends/SignDocuments/src/Component/component/header.js @@ -27,13 +27,13 @@ function Header({ signersdata, isMailSend, alertSendEmail, - isSigned, isCompleted, isShowHeader, decline, currentSigner, dataTut4, - alreadySign + alreadySign, + isSignYourself }) { const isMobile = window.innerWidth < 767; const navigate = useNavigate(); @@ -61,12 +61,19 @@ function Header({ const pdf = await getBase64FromUrl(pdfUrl); const isAndroidDevice = navigator.userAgent.match(/Android/i); - const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream + const isAppleDevice = + (/iPad|iPhone|iPod/.test(navigator.platform) || + (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) && + !window.MSStream; if (isAndroidDevice || isAppleDevice) { - const byteArray = Uint8Array.from(atob(pdf).split('').map(char => char.charCodeAt(0))); - const blob = new Blob([byteArray], { type: 'application/pdf' }); + const byteArray = Uint8Array.from( + atob(pdf) + .split("") + .map((char) => char.charCodeAt(0)) + ); + const blob = new Blob([byteArray], { type: "application/pdf" }); const blobUrl = URL.createObjectURL(blob); - window.open(blobUrl, '_blank'); + window.open(blobUrl, "_blank"); } else { printModule({ printable: pdf, type: "pdf", base64: true }); } @@ -75,19 +82,76 @@ function Header({ //handle download signed pdf const handleDownloadPdf = () => { const pdfName = pdfDetails[0] && pdfDetails[0].Name; - - saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`); + saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`); }; - + const sanitizeFileName = (pdfName) => { // Replace spaces with underscore return pdfName.replace(/ /g, '_'); } - - + //certificate generate and download component in mobile view + const CertificateDropDown = () => { + //after generate download certifcate pdf + const handleDownload = (pdfBlob, fileName) => { + if (pdfBlob) { + const url = window.URL.createObjectURL(pdfBlob); + // Create a temporary anchor element + const link = document.createElement("a"); + link.href = url; + link.download = fileName; + // Append the anchor to the body + document.body.appendChild(link); + // Programmatically click the anchor to trigger the download + link.click(); + // Remove the anchor from the body + document.body.removeChild(link); + // Release the object URL to free up resources + window.URL.revokeObjectURL(url); + } + }; + return ( + e.preventDefault()} + style={{ textDecoration: "none", zIndex: "35" }} + document={} + > + {({ blob, url, loading, error }) => ( + <> + {loading ? ( + "Loading document..." + ) : ( +
+ handleDownload( + blob, + `completion certificate-${ + pdfDetails[0] && pdfDetails[0].Name + }.pdf` + ) + } + > + + Certificate +
+ )} + + )} +
+ ); + }; return (
{isMobile && isShowHeader ? ( @@ -95,7 +159,9 @@ function Header({ id="navbar" className={isGuestSigner ? "stickySignerHead" : "stickyHead"} style={{ - width: isGuestSigner ? window.innerWidth : window.innerWidth - 30 + "px" + width: isGuestSigner + ? window.innerWidth + : window.innerWidth - 30 + "px" }} >
@@ -140,16 +206,16 @@ function Header({ style={{ color: "gray", cursor: "pointer" }} >
- {pdfUrl ? ( + {pdfUrl && alreadySign ? (
handleDownloadPdf()} style={{ color: themeColor(), border: "none", fontWeight: "650", - fontSize: "16px" + fontSize: "16px", + padding:"0px 3px 0px 5px" }} > @@ -179,51 +245,46 @@ function Header({ Download
- - } - fileName={`completion certificate-${ - pdfDetails[0] && pdfDetails[0].Name - }.pdf`} + {recipient && pdfDetails[0] && pdfDetails.length > 0 ? ( + + + + ) : isPdfRequestFiles && + alreadySign && + isCompleted.isCertificate ? ( + + + + ) :isSignYourself && ( + + + + )} + +
- {({ blob, url, loading, error }) => ( - <> - {console.log("error", error)} - {loading ? ( - "Loading document..." - ) : ( - - )} - - )} - + {" "} + + Print +
) : (
- {/* current signer is checking user send request and check status of pdf sign than if current + {/* current signer is checking user send request and check status of pdf sign than if current user exist than show finish button else no */} {currentSigner && ( @@ -267,6 +328,8 @@ function Header({ onClick={() => { if (!pdfUrl) { embedImages(); + } else if (isPdfRequestFiles) { + embedImages(); } }} style={{ @@ -689,4 +752,4 @@ function Header({ ); } -export default Header; +export default Header; \ No newline at end of file diff --git a/microfrontends/SignDocuments/src/Component/component/renderPdf.js b/microfrontends/SignDocuments/src/Component/component/renderPdf.js index abebeb5db..07cade06e 100644 --- a/microfrontends/SignDocuments/src/Component/component/renderPdf.js +++ b/microfrontends/SignDocuments/src/Component/component/renderPdf.js @@ -42,7 +42,8 @@ function RenderPdf({ const isMobile = window.innerWidth < 767; const newWidth = window.innerWidth; const scale = isMobile ? pdfOriginalWidth / newWidth : 1; - + //check isGuestSigner is present in local if yes than handle login flow header in mobile view + const isGuestSigner = localStorage.getItem("isGuestSigner"); // handle signature block width and height according to screen const posWidth = (pos) => { let width; @@ -74,8 +75,7 @@ function RenderPdf({ return width; } }; - //check isGuestSigner is present in local if yes than handle login flow header in mobile view - const isGuestSigner = localStorage.getItem("isGuestSigner"); + //function for render placeholder block over pdf document const checkSignedSignes = (data) => { @@ -777,7 +777,13 @@ function RenderPdf({ }} onLoadSuccess={pageDetails} ref={pdfRef} - file={pdfUrl ? pdfUrl : pdfDetails[0] && pdfDetails[0].URL} + file={ + pdfUrl + ? pdfUrl + : pdfDetails[0] && pdfDetails[0].SignedUrl + ? pdfDetails[0].SignedUrl + : pdfDetails[0].URL + } > {Array.from(new Array(numPages), (el, index) => ( {Array.from(new Array(numPages), (el, index) => (