🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix: initial signature issue
RaktimaNXGf4e907de3671
diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.jsindex 91266cffd..b0354a8b3 100644--- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js+++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js@@ -285,6 +285,7 @@ function PdfRequestFiles() {const getcurrentUserPosition = documentData[0].Placeholders.filter((data) => data.signerObjId === currUserId);+const getPlacecholder = getcurrentUserPosition[0].placeHolder;const checkInitialExist = isInitialValueExist(getPlacecholder);@@ -293,7 +294,19 @@ function PdfRequestFiles() {} else if (checkInitialExist) {setIsInitialSign(true);}+ } else {+ const getcurrentUserPosition = documentData[0].Placeholders.filter(+ (data) => data.signerObjId === currUserId+ );++ const getPlacecholder = getcurrentUserPosition[0].placeHolder;+ const checkInitialExist = isInitialValueExist(getPlacecholder);++ if (checkInitialExist) {+ setIsInitialSign(true);+ }}+const loadObj = {isLoad: false};@@ -303,6 +316,7 @@ function PdfRequestFiles() {const loadObj = {isLoad: false};+setHandleError("Error: Something went wrong!");setIsLoading(loadObj);});@@ -1030,13 +1044,7 @@ function PdfRequestFiles() {</div></div>)}- <ModalUi- isOpen={isInitialSign}- title={"Add Initial signature"}- handleClose={() => {- setIsInitialSign(false);- }}- >+ <ModalUi isOpen={isInitialSign} title={"Add Initial signature"}><div style={{ height: "100%", padding: 20 }}><p>Please add your initial signature</p>diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.jsindex 2dfc58da9..5d7b2ee51 100644--- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js+++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js@@ -380,7 +380,14 @@ function SignYourSelf() {const x = offset.x - containerRect.left;const y = offset.y - containerRect.top;const ybottom = containerRect.bottom - offset.y;-+ const widgetData =+ item.text === "name"+ ? pdfDetails[0].ExtUserPtr.Name+ : item.text === "company"+ ? pdfDetails[0].ExtUserPtr.Company+ : item.text === "job title"+ ? pdfDetails[0].ExtUserPtr.JobTitle+ : "";dropObj = {xPosition: signBtnPosition[0] ? x - signBtnPosition[0].xPos : x,yPosition: signBtnPosition[0] ? y - signBtnPosition[0].yPos : y,@@ -392,25 +399,18 @@ function SignYourSelf() {yBottom: ybottom,type: item.text,SignUrl: item.text === "initials" && initial,- widgetValue:- item.text === "name"- ? pdfDetails[0].ExtUserPtr.Name- : item.text === "company"- ? pdfDetails[0].ExtUserPtr.Company- : item.text === "job title"- ? pdfDetails[0].ExtUserPtr.JobTitle- : "",+ widgetValue: widgetData,Width:item.text === "name" ||item.text === "company" ||item.text === "job title"- ? calculateInitialWidthHeight(item.text, pdfDetails[0]).getWidth+ ? calculateInitialWidthHeight(item.text, widgetData).getWidth: "",Height:item.text === "company" ||item.text === "name" ||item.text === "job title"- ? calculateInitialWidthHeight(item.text, pdfDetails[0]).getHeight+ ? calculateInitialWidthHeight(item.text, widgetData).getHeight: ""};diff --git a/microfrontends/SignDocuments/src/Component/WidgetComponent/placeholderType.js b/microfrontends/SignDocuments/src/Component/WidgetComponent/placeholderType.jsindex 1b2a1f1e1..d76791e17 100644--- a/microfrontends/SignDocuments/src/Component/WidgetComponent/placeholderType.js+++ b/microfrontends/SignDocuments/src/Component/WidgetComponent/placeholderType.js@@ -7,7 +7,17 @@ function PlaceholderType(props) {const handleInputBlur = () => {props.setDraggingEnabled(true);};+useEffect(() => {+ const senderUser =+ localStorage.getItem(+ `Parse/${localStorage.getItem("parseAppId")}/currentUser`+ ) &&+ localStorage.getItem(+ `Parse/${localStorage.getItem("parseAppId")}/currentUser`+ );+ const jsonSender = JSON.parse(senderUser);+if (props.isNeedSign && props.data?.signerObjId === props.signerObjId) {onChangeInput(props.pdfDetails,@@ -16,7 +26,8 @@ function PlaceholderType(props) {null,props.setXyPostion,props.signerObjId,- props.initial+ props.initial,+ jsonSender.name);}}, [type]);@@ -233,11 +244,7 @@ function PlaceholderType(props) {<inputclassName="inputPlaceholder"type="text"- value={- props.pos.widgetValue- ? props.pos.widgetValue- : props.pdfDetails.ExtUserPtr.Company- }+ value={props.pos.widgetValue && props.pos.widgetValue}onChange={(e) =>onChangeInput(e.target.value,@@ -276,11 +283,7 @@ function PlaceholderType(props) {<inputclassName="inputPlaceholder"type="text"- value={- props.pos.widgetValue- ? props.pos.widgetValue- : props.pdfDetails.ExtUserPtr.JobTitle- }+ value={props.pos.widgetValue && props.pos.widgetValue}onChange={(e) =>onChangeInput(e.target.value,diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.jsindex 210b53dc5..c4c6473d7 100644--- a/microfrontends/SignDocuments/src/utils/Utils.js+++ b/microfrontends/SignDocuments/src/utils/Utils.js@@ -4,13 +4,8 @@ import { themeColor } from "./ThemeColor/backColor";const isMobile = window.innerWidth < 767;//calculate width and height-export const calculateInitialWidthHeight = (type, pdfDetails) => {- const intialText =- type === "name"- ? pdfDetails.ExtUserPtr.Name- : type === "company"- ? pdfDetails.ExtUserPtr.Company- : type === "job title" && pdfDetails.ExtUserPtr.JobTitle;+export const calculateInitialWidthHeight = (type, widgetData) => {+ const intialText = widgetData;const span = document.createElement("span");span.textContent = intialText;span.style.font = `14px`; // here put your text size and font family@@ -30,7 +25,8 @@ export const addInitialData = (setXyPostion,value,initial,- signerObjId+ signerObjId,+ jsonSender) => {return signerPos.map((item) => {if (item.placeHolder && item.placeHolder.length > 0) {@@ -42,7 +38,9 @@ export const addInitialData = (item.placeHolder,setXyPostion,value,- initial+ initial,+ signerObjId,+ jsonSender)};} else {@@ -54,13 +52,20 @@ export const addInitialData = (// If there is no nested array, add the new fieldreturn {...item,- pos: addInitialData(item.pos, setXyPostion, value, initial)+ pos: addInitialData(+ item.pos,+ setXyPostion,+ value,+ initial,+ signerObjId,+ jsonSender+ )// Adjust this line to add the desired field};} else {const widgetData =item.type === "name"- ? value.ExtUserPtr.Name+ ? jsonSender: item.type === "company"? value.ExtUserPtr.Company: item.type === "job title" && value.ExtUserPtr.JobTitle;@@ -77,8 +82,8 @@ export const addInitialData = (return {...item,widgetValue: widgetData,- Width: calculateInitialWidthHeight(item.type, value).getWidth,- Height: calculateInitialWidthHeight(item.type, value).getHeight+ Width: calculateInitialWidthHeight(item.type, widgetData).getWidth,+ Height: calculateInitialWidthHeight(item.type, widgetData).getHeight};} else {return {@@ -95,10 +100,11 @@ export const onChangeInput = (index,setXyPostion,signerObjId,- initial+ initial,+ jsonSender) => {const isSigners = xyPostion.some((data) => data.signerPtr);-+ console.log(signerObjId);if (isSigners) {const filterSignerPos = xyPostion.filter((data) => data.signerObjId === signerObjId@@ -111,7 +117,8 @@ export const onChangeInput = (setXyPostion,value,initial,- signerObjId+ signerObjId,+ jsonSender);setXyPostion(xyData);} else {