diff --git a/apps/OpenSign/src/components/pdf/PdfHeader.js b/apps/OpenSign/src/components/pdf/PdfHeader.js index 771770ced..f006a8efc 100644 --- a/apps/OpenSign/src/components/pdf/PdfHeader.js +++ b/apps/OpenSign/src/components/pdf/PdfHeader.js @@ -1,7 +1,5 @@ import React from "react"; import PrevNext from "./PrevNext"; -import { PDFDownloadLink } from "@react-pdf/renderer"; -import Certificate from "./Certificate"; import printModule from "print-js"; import { getBase64FromUrl } from "../../constant/Utils"; import { saveAs } from "file-saver"; @@ -13,14 +11,11 @@ import { themeColor } from "../../constant/const"; function Header({ isPdfRequestFiles, isPlaceholder, - recipient, setIsDecline, pageNumber, - isAlreadySign, allPages, changePage, pdfUrl, - documentStatus, embedWidgetsData, pdfDetails, signerPos, @@ -94,109 +89,15 @@ function Header({ // 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, loading }) => ( - <> - {loading ? ( -
- - Certificate -
- ) : ( -
- handleDownload( - blob, - `completion certificate-${ - pdfDetails[0] && pdfDetails[0].Name - }.pdf` - ) - } - > - - Certificate -
- )} - - )} -
- ); - }; - const CertificateComponent = () => { - return ( - } - fileName={`completion certificate-${ - pdfDetails[0] && pdfDetails[0].Name - }.pdf`} - > - {({ loading }) => ( - - )} - - ); + //handle download signed pdf + const handleDownloadCertificate = () => { + if (pdfDetails?.length > 0 && pdfDetails[0]?.CertificateUrl) { + const certificateUrl = pdfDetails[0] && pdfDetails[0]?.CertificateUrl; + saveAs(certificateUrl, `Certificate_signed_by_OpenSign™.pdf`); + } }; + return (
{isMobile && isShowHeader ? ( @@ -210,11 +111,7 @@ function Header({ }} >
-
{ - navigate(-1); - }} - > +
navigate(-1)}>
- - {recipient && pdfDetails[0] && pdfDetails.length > 0 ? ( - - + {isCompleted && ( + handleDownloadCertificate()} + > +
+ + Certificate +
- ) : isPdfRequestFiles && - alreadySign && - isCompleted.isCertificate ? ( - - + )} + {isSignYourself && ( + setIsEmail(true)} + > +
+ + Mail +
- ) : ( - isSignYourself && ( - <> - - - - setIsEmail(true)} - > -
- - Mail -
-
- - ) )} - {" "}