From b77b57d3fddde06a8fdff8ada103ae8daab47f10 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Fri, 8 Nov 2024 12:34:21 +0530 Subject: [PATCH] fix: signature type not visible in signpad for public template --- apps/OpenSign/src/components/pdf/SignPad.js | 4 +- apps/OpenSign/src/pages/DraftTemplate.js | 24 +++------ apps/OpenSign/src/pages/PdfRequestFiles.js | 54 +++++++++++-------- apps/OpenSign/src/pages/PlaceHolderSign.js | 28 ++++------ .../OpenSign/src/pages/TemplatePlaceholder.js | 24 +++------ 5 files changed, 57 insertions(+), 77 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 340b3ab8f..414805876 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -37,11 +37,13 @@ function SignPad(props) { useEffect(() => { handleTab(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [props.signatureTypes]); + function handleTab() { const signtypes = props?.signatureTypes || []; const index = signtypes?.findIndex((x) => x.enabled === true); if (index !== -1) { + setIsSignTypes(true); const tab = props?.signatureTypes[index].name; if (tab === "draw") { setIsTab("draw"); diff --git a/apps/OpenSign/src/pages/DraftTemplate.js b/apps/OpenSign/src/pages/DraftTemplate.js index f6b04d021..a38991985 100644 --- a/apps/OpenSign/src/pages/DraftTemplate.js +++ b/apps/OpenSign/src/pages/DraftTemplate.js @@ -248,15 +248,18 @@ const DraftTemplate = () => { } if (documentData && documentData.length > 0) { - const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes; + if (isEnableSubscription) { + checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email); + } + const userSignatureType = + documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes; + const docSignTypes = + documentData?.[0]?.SignatureType || userSignatureType; const updatedSignatureType = await handleSignatureType( tenantSignTypes, docSignTypes ); setSignatureType(updatedSignatureType); - if (isEnableSubscription) { - checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email); - } const updatedPdfDetails = [...documentData]; updatedPdfDetails[0].SignatureType = updatedSignatureType; setPdfDetails(updatedPdfDetails); @@ -327,19 +330,6 @@ const DraftTemplate = () => { const res = await contractUsers(jwttoken); if (res[0] && res.length) { - const userSignatureType = res[0]?.SignatureType || signatureTypes; - const docSignTypes = - documentData?.[0]?.SignatureType || userSignatureType; - const updatedSignatureType = await handleSignatureType( - tenantSignTypes, - docSignTypes - ); - setSignatureType(updatedSignatureType); - if (documentData?.length && documentData?.[0]?.objectId) { - const updatedPdfDetails = [...documentData]; - updatedPdfDetails[0].SignatureType = updatedSignatureType; - setPdfDetails(updatedPdfDetails); - } setSignerUserId(res[0].objectId); const tourstatus = res[0].TourStatus && res[0].TourStatus; if (tourstatus && tourstatus.length > 0) { diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index 345397a4d..a0b84c848 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -421,12 +421,18 @@ function PdfRequestFiles(props) { //getting document details const documentData = await contractDocument(docId); if (documentData && documentData.length > 0) { - const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes; + const userSignatureType = + documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes; + const docSignTypes = + documentData?.[0]?.SignatureType || userSignatureType; const updatedSignatureType = await handleSignatureType( tenantSignTypes, docSignTypes ); setSignatureType(updatedSignatureType); + const updatedPdfDetails = [...documentData]; + updatedPdfDetails[0].SignatureType = updatedSignatureType; + setPdfDetails(updatedPdfDetails); const url = documentData[0] && (documentData[0]?.SignedUrl || documentData[0]?.URL); @@ -2130,28 +2136,30 @@ function PdfRequestFiles(props) { {/* this component is used for signature pad modal */} - + {documentId && ( + + )} {/* pdf header which contain funish back button */}
0) { const url = documentData[0] && documentData[0]?.URL; - const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes; - const updatedSignatureType = await handleSignatureType( - tenantSignTypes, - docSignTypes - ); - setSignatureType(updatedSignatureType); //convert document url in array buffer format to use embed widgets in pdf using pdf-lib const arrayBuffer = await convertPdfArrayBuffer(url); if (arrayBuffer === "Error") { @@ -320,6 +314,15 @@ function PlaceHolderSign() { }); } } + const userSignatureType = + documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes; + const docSignTypes = + documentData?.[0]?.SignatureType || userSignatureType; + const updatedSignatureType = await handleSignatureType( + tenantSignTypes, + docSignTypes + ); + setSignatureType(updatedSignatureType); const updatedPdfDetails = [...documentData]; updatedPdfDetails[0].SignatureType = updatedSignatureType; setPdfDetails(updatedPdfDetails); @@ -445,19 +448,6 @@ function PlaceHolderSign() { setHandleError(t("something-went-wrong-mssg")); setIsLoading({ isLoad: false }); } else if (res.length && res[0]?.objectId) { - const userSignatureType = res[0]?.SignatureType || signatureTypes; - const docSignTypes = - documentData?.[0]?.SignatureType || userSignatureType; - const updatedSignatureType = await handleSignatureType( - tenantSignTypes, - docSignTypes - ); - setSignatureType(updatedSignatureType); - if (documentData?.length && documentData?.[0]?.objectId) { - const updatedPdfDetails = [...documentData]; - updatedPdfDetails[0].SignatureType = updatedSignatureType; - setPdfDetails(updatedPdfDetails); - } setActiveMailAdapter(res[0]?.active_mail_adapter); setSignerUserId(res[0].objectId); const tourstatus = res[0].TourStatus && res[0].TourStatus; diff --git a/apps/OpenSign/src/pages/TemplatePlaceholder.js b/apps/OpenSign/src/pages/TemplatePlaceholder.js index 91f247564..c529141e3 100644 --- a/apps/OpenSign/src/pages/TemplatePlaceholder.js +++ b/apps/OpenSign/src/pages/TemplatePlaceholder.js @@ -236,15 +236,18 @@ const TemplatePlaceholder = () => { : []; if (documentData && documentData.length > 0) { - const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes; + if (isEnableSubscription) { + checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email); + } + const userSignatureType = + documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes; + const docSignTypes = + documentData?.[0]?.SignatureType || userSignatureType; const updatedSignatureType = await handleSignatureType( tenantSignTypes, docSignTypes ); setSignatureType(updatedSignatureType); - if (isEnableSubscription) { - checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email); - } const updatedPdfDetails = [...documentData]; updatedPdfDetails[0].SignatureType = updatedSignatureType; setPdfDetails(updatedPdfDetails); @@ -314,19 +317,6 @@ const TemplatePlaceholder = () => { } const res = await contractUsers(); if (res[0] && res.length) { - const userSignatureType = res[0]?.SignatureType || signatureTypes; - const docSignTypes = - documentData?.[0]?.SignatureType || userSignatureType; - const updatedSignatureType = await handleSignatureType( - tenantSignTypes, - docSignTypes - ); - setSignatureType(updatedSignatureType); - if (documentData?.length && documentData?.[0]?.objectId) { - const updatedPdfDetails = [...documentData]; - updatedPdfDetails[0].SignatureType = updatedSignatureType; - setPdfDetails(updatedPdfDetails); - } setSignerUserId(res[0].objectId); setCurrentEmail(res[0].Email); const tourstatus = res[0].TourStatus && res[0].TourStatus;