From ec4d875547532d64d7dcff5e61481749c625cdc3 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Wed, 18 Sep 2024 18:09:18 +0530 Subject: [PATCH] fix: blank page appear when try to add typed signature --- apps/OpenSign/src/components/pdf/SignPad.js | 18 ++++++++++-------- apps/OpenSign/src/pages/TemplatePlaceholder.js | 1 + .../PublicUserLinkContactToDoc.js | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 33c61eb67..37772445c 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -31,8 +31,8 @@ function SignPad({ const [isTab, setIsTab] = useState("draw"); const [isSignImg, setIsSignImg] = useState(""); const [signValue, setSignValue] = useState(""); - const [textWidth, setTextWidth] = useState(null); - const [textHeight, setTextHeight] = useState(null); + const [textWidth, setTextWidth] = useState(0); + const [textHeight, setTextHeight] = useState(0); const [signatureType, setSignatureType] = useState("draw"); const fontOptions = [ { value: "Fasthand" }, @@ -51,7 +51,7 @@ function SignPad({ `Parse/${localStorage.getItem("parseAppId")}/currentUser` ); const jsonSender = JSON.parse(senderUser); - const currentUserName = jsonSender && jsonSender.name; + const currentUserName = jsonSender && jsonSender?.name; //function for clear signature image const handleClear = () => { @@ -137,7 +137,7 @@ function SignPad({ (isTab === "draw" && isSignImg) || (isTab === "image" && image) || (isTab === "mysignature" && isDefaultSign) || - (isTab === "type" && textWidth) + (isTab === "type" && signValue) ? false : image ? false @@ -169,10 +169,10 @@ function SignPad({ } } - const trimmedName = currentUserName && currentUserName.trim(); + const trimmedName = currentUserName && currentUserName?.trim(); const firstCharacter = trimmedName?.charAt(0); const userName = isInitial ? firstCharacter : currentUserName; - setSignValue(userName); + setSignValue(userName || ""); setFontSelect("Fasthand"); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -200,8 +200,10 @@ function SignPad({ canvasRef.current.fromDataURL(isSignImg); } if (isTab === "type") { - const trimmedName = signValue ? signValue.trim() : currentUserName.trim(); - const firstCharacter = trimmedName.charAt(0); + const trimmedName = signValue + ? signValue?.trim() + : currentUserName?.trim(); + const firstCharacter = trimmedName?.charAt(0); const userName = isInitial ? firstCharacter : signValue; setSignValue(userName); convertToImg(fontSelect, userName); diff --git a/apps/OpenSign/src/pages/TemplatePlaceholder.js b/apps/OpenSign/src/pages/TemplatePlaceholder.js index 96cacac81..d602ba4ac 100644 --- a/apps/OpenSign/src/pages/TemplatePlaceholder.js +++ b/apps/OpenSign/src/pages/TemplatePlaceholder.js @@ -779,6 +779,7 @@ const TemplatePlaceholder = () => { AutomaticReminders: pdfDetails[0]?.AutomaticReminders, RemindOnceInEvery: parseInt(pdfDetails[0]?.RemindOnceInEvery), NextReminderDate: pdfDetails[0]?.NextReminderDate, + IsEnableOTP: pdfDetails[0]?.IsEnableOTP === "true" ? true : false, URL: pdfUrl }; const updateTemplate = new Parse.Object("contracts_Template"); diff --git a/apps/OpenSignServer/cloud/parsefunction/PublicUserLinkContactToDoc.js b/apps/OpenSignServer/cloud/parsefunction/PublicUserLinkContactToDoc.js index 5c2e16532..863769996 100644 --- a/apps/OpenSignServer/cloud/parsefunction/PublicUserLinkContactToDoc.js +++ b/apps/OpenSignServer/cloud/parsefunction/PublicUserLinkContactToDoc.js @@ -62,6 +62,7 @@ const createDocumentFromTemplate = async (template, existContact, index) => { object.set('CreatedBy', template?.CreatedBy); object.set('ExtUserPtr', template?.ExtUserPtr); object.set('OriginIp', template?.OriginIp || ''); + object.set('IsEnableOTP', template?.IsEnableOTP || false); let signers = template?.Signers || []; const signerobj = { __type: 'Pointer',