import React from "react"; import PrevNext from "./prevNext"; import { PDFDownloadLink } from "@react-pdf/renderer"; import Certificate from "../Certificate/Certificate"; import printModule from "print-js"; import { getBase64FromUrl } from "../../utils/Utils"; import { saveAs } from "file-saver"; import "../../css/signature.css"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; import { useNavigate } from "react-router-dom"; import { themeColor } from "../../utils/ThemeColor/backColor"; function Header({ isPdfRequestFiles, isPlaceholder, recipient, setIsDecline, pageNumber, isAlreadySign, allPages, changePage, pdfUrl, documentStatus, embedImages, pdfDetails, signerPos, signersdata, isMailSend, alertSendEmail, isSigned, isCompleted, isShowHeader, decline, currentSigner, }) { const isMobile = window.innerWidth < 712; const navigate = useNavigate(); //for go to previous page function previousPage() { changePage(-1); } //for go to next page function nextPage() { changePage(1); } //function for show decline alert const handleDeclinePdfAlert = async () => { const currentDecline = { currnt: "Sure", isDeclined: true, }; setIsDecline(currentDecline); }; //function for print digital sign pdf const handleToPrint = async (event) => { event.preventDefault(); const pdf = await getBase64FromUrl(pdfUrl); printModule({ printable: pdf, type: "pdf", base64: true }); }; //handle download signed pdf const handleDownloadPdf = () => { const pdfName = pdfDetails[0] && pdfDetails[0].Name; saveAs(pdfUrl, `${pdfName}_signed_by_opensign.qik.ai.pdf`); }; return (
{recipient ? ( pdfUrl || isAlreadySign.mssg ? (
{pdfDetails[0] && pdfDetails.length > 0 && ( // } fileName={`completion certificate-${ pdfDetails[0] && pdfDetails[0].Name }.pdf`} > {({ blob, url, loading, error }) => loading ? ( "Loading document..." ) : ( ) } )}
) : (
) ) : pdfUrl || (documentStatus && documentStatus.isCompleted) ? (
} fileName={`completion certificate-${ pdfDetails[0] && pdfDetails[0].Name }.pdf`} > {({ blob, url, loading, error }) => loading ? ( "Loading document..." ) : ( ) }
) : isPlaceholder ? ( <> {!isMailSend && signersdata.Signers && signersdata.Signers.length !== signerPos.length && (
{signerPos.length === 0 ? ( Add all {signersdata.Signers.length - signerPos.length}{" "} recipients signature ) : ( Add {signersdata.Signers.length - signerPos.length} more recipients signature )}
)}
) : isPdfRequestFiles ? ( isSigned ? (
{isCompleted.isCertificate && ( } fileName={`completion certificate-${ pdfDetails[0] && pdfDetails[0].Name }.pdf`} > {({ blob, url, loading, error }) => loading ? ( "Loading document..." ) : ( ) } )}
) : (
{currentSigner && ( <> )}
) ) : (
)}
{isMobile && isShowHeader && ( )}
); } export default Header;