From b75016aaa07d2ef27f7e051b8fbfc9ce5773f3ce Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Mon, 30 Oct 2023 16:31:21 +0530 Subject: [PATCH] handle reactour for recipients,pdf loading, resolve warnings --- .../SignDocuments/src/Component/ManageSign.js | 25 +- .../src/Component/PdfRequestFiles.js | 103 +- .../src/Component/SignYourselfPdf.js | 135 +- .../Component/component/fieldsComponent.js | 2 +- .../src/Component/component/header.js | 3 + .../src/Component/component/renderPdf.js | 1441 +++++++++-------- .../SignDocuments/src/Component/login.js | 3 +- .../src/Component/placeHolderSign.js | 147 +- .../src/Component/recipientSignPdf.js | 131 +- .../SignDocuments/src/utils/Utils.js | 108 +- 10 files changed, 1079 insertions(+), 1019 deletions(-) diff --git a/microfrontends/SignDocuments/src/Component/ManageSign.js b/microfrontends/SignDocuments/src/Component/ManageSign.js index 050ecb021..3fbd113db 100644 --- a/microfrontends/SignDocuments/src/Component/ManageSign.js +++ b/microfrontends/SignDocuments/src/Component/ManageSign.js @@ -515,20 +515,20 @@ const ManageSign = () => { border: "none", margin: "5px", borderBottom: - key == 0 && penColor == "blue" + key === 0 && penColor === "blue" ? "2px solid blue" - : key == 1 && penColor == "red" + : key === 1 && penColor === "red" ? "2px solid red" - : key == 2 && penColor == "black" + : key === 2 && penColor === "black" ? "2px solid black" : "2px solid white", }} onClick={() => { - if (key == 0) { + if (key === 0) { setPenColor("blue"); - } else if (key == 1) { + } else if (key === 1) { setPenColor("red"); - } else if (key == 2) { + } else if (key === 2) { setPenColor("black"); } }} @@ -629,24 +629,25 @@ const ManageSign = () => { {allColor.map((data, key) => { return ( pen { - if (key == 0) { + if (key === 0) { setInitialPen("blue"); - } else if (key == 1) { + } else if (key === 1) { setInitialPen("red"); - } else if (key == 2) { + } else if (key === 2) { setInitialPen("black"); } }} diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js index 9a88fa42e..f9ff8662e 100644 --- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js +++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js @@ -1,6 +1,5 @@ import React, { useState, useRef, useEffect } from "react"; import { themeColor } from "../utils/ThemeColor/backColor"; - import { PDFDocument, rgb } from "pdf-lib"; import "../css/signature.css"; import axios from "axios"; @@ -16,7 +15,7 @@ import { contactBook, contractUsers, getBase64FromIMG, - getBase64FromUrl, + getBase64FromUrl } from "../utils/Utils"; import Loader from "./component/loader"; import HandleError from "./component/HandleError"; @@ -44,7 +43,7 @@ function PdfRequestFiles() { const [handleError, setHandleError] = useState(); const [isLoading, setIsLoading] = useState({ isLoad: true, - message: "This might take some time", + message: "This might take some time" }); const [defaultSignImg, setDefaultSignImg] = useState(); const [isDocId, setIsDocId] = useState(false); @@ -58,7 +57,11 @@ function PdfRequestFiles() { const [currentSigner, setCurrentSigner] = useState(false); const [isCompleted, setIsCompleted] = useState({ isCertificate: false, - isModal: false, + isModal: false + }); + const [pdfLoadFail, setPdfLoadFail] = useState({ + status: false, + type: "load" }); const [isSigned, setIsSigned] = useState(false); const [isExpired, setIsExpired] = useState(false); @@ -104,7 +107,7 @@ function PdfRequestFiles() { setSignerObjectId(objId); } else if (contractUsersRes === "Error: Something went wrong!") { const loadObj = { - isLoad: false, + isLoad: false }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); @@ -126,8 +129,8 @@ function PdfRequestFiles() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -149,13 +152,13 @@ function PdfRequestFiles() { setIsSigned(true); const data = { isCertificate: true, - isModal: true, + isModal: true }; setIsCompleted(data); } else if (declined) { const currentDecline = { currnt: "another", - isDeclined: true, + isDeclined: true }; setIsDecline(currentDecline); } else if (currDate > expireUpdateDate) { @@ -226,7 +229,7 @@ function PdfRequestFiles() { // alert("No data found!"); setNoData(true); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); setIsUiLoading(false); @@ -235,7 +238,7 @@ function PdfRequestFiles() { .catch((err) => { console.log("err", err); const loadObj = { - isLoad: false, + isLoad: false }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); @@ -251,8 +254,8 @@ function PdfRequestFiles() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -263,13 +266,13 @@ function PdfRequestFiles() { setDefaultSignImg(res[0].ImageURL); } const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); }) .catch((err) => { const loadObj = { - isLoad: false, + isLoad: false }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); @@ -311,7 +314,7 @@ function PdfRequestFiles() { ); const pdfDoc = await PDFDocument.load(existingPdfBytes, { - ignoreEncryption: true, + ignoreEncryption: true }); let pdfBase64; @@ -336,11 +339,11 @@ function PdfRequestFiles() { y: page.getHeight() - 10, size: fontSize, font, - color: rgb(0.5, 0.5, 0.5), + color: rgb(0.5, 0.5, 0.5) }); } pdfBase64 = await pdfDoc.saveAsBase64({ - useObjectStreams: false, + useObjectStreams: false }); } @@ -423,7 +426,7 @@ function PdfRequestFiles() { y: page.getHeight() - 10, size: fontSize, font, - color: rgb(0.5, 0.5, 0.5), + color: rgb(0.5, 0.5, 0.5) }); } @@ -474,12 +477,12 @@ function PdfRequestFiles() { x: imgUrlList[id].xPosition, y: page.getHeight() - imgUrlList[id].yPosition - imgHeight, width: imgWidth, - height: imgHeight, + height: imgHeight }); }); } const pdfBytes = await pdfDoc.saveAsBase64({ - useObjectStreams: false, + useObjectStreams: false }); signPdfFun(pdfBytes, documentId, pngUrl); @@ -524,8 +527,8 @@ function PdfRequestFiles() { Bottom: bottomY, Width: xyPosData.Width ? xyPosData.Width : 150, Height: height, - Page: pageNo, - }, + Page: pageNo + } }; } else if ( xyPosData && @@ -534,7 +537,7 @@ function PdfRequestFiles() { ) { signgleSign = { pdfFile: base64Url, - docId: documentId, + docId: documentId }; } @@ -546,8 +549,8 @@ function PdfRequestFiles() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - sessionToken: localStorage.getItem("accesstoken"), - }, + sessionToken: localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -569,6 +572,10 @@ function PdfRequestFiles() { }; //function for get pdf page details const pageDetails = async (pdf) => { + const load = { + status: true + }; + setPdfLoadFail(load); pdf.getPage(1).then((pdfPage) => { const pageWidth = pdfPage.view[2]; @@ -666,7 +673,7 @@ function PdfRequestFiles() { Width: newWidth, Height: nweHeight, SignUrl: image.src, - ImageType: image.imgType, + ImageType: image.imgType }; } return url; @@ -715,7 +722,7 @@ function PdfRequestFiles() { Width: newWidth, Height: nweHeight, SignUrl: image.src, - ImageType: image.imgType, + ImageType: image.imgType }; } return url; @@ -801,7 +808,7 @@ function PdfRequestFiles() { //function for set decline true on press decline button const declineDoc = async () => { const data = { - IsDeclined: true, + IsDeclined: true }; setIsUiLoading(true); @@ -815,8 +822,8 @@ function PdfRequestFiles() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((result) => { @@ -824,7 +831,7 @@ function PdfRequestFiles() { if (res) { const currentDecline = { currnt: "YouDeclined", - isDeclined: true, + isDeclined: true }; setIsDecline(currentDecline); setIsUiLoading(false); @@ -859,7 +866,7 @@ function PdfRequestFiles() { alignItems: "center", zIndex: "20", backgroundColor: "#e6f2f2", - opacity: 0.8, + opacity: 0.8 }} > 500 && "20px", - marginRight: pdfOriginalWidth > 500 && "20px", + marginRight: pdfOriginalWidth > 500 && "20px" }} > @@ -927,7 +934,7 @@ function PdfRequestFiles() { <>

This is an automated email from Open Sign. For any queries regarding this email, please contact the sender " + sender + - " directly.If you think this email is inappropriate or spam, you may file a complaint with Open Sign here.

", + " directly.If you think this email is inappropriate or spam, you may file a complaint with Open Sign here.

" }; sendMail = await axios.post(url, params, { headers: headers }); } catch (error) { @@ -780,11 +782,8 @@ function PlaceHolderSign() { try { const data = { Placeholders: signerPos, - SignedUrl: pdfDetails[0].URL, + SignedUrl: pdfDetails[0].URL }; - const isMobile = window.innerWidth < 712; - const newWidth = window.innerWidth; - const scale = isMobile ? pdfOriginalWidth / newWidth : 1; await axios .put( @@ -796,8 +795,8 @@ function PlaceHolderSign() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((result) => { @@ -805,7 +804,7 @@ function PlaceHolderSign() { setIsSend(true); setIsMailSend(true); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); // console.log("save res", res); @@ -826,26 +825,26 @@ function PlaceHolderSign() { content: `Select a recipient from this list to add a place-holder where he is supposed to sign.The placeholder will appear in the same colour as the recipient name once you drop it on the document.`, position: "top", - style: { fontSize: "13px" }, + style: { fontSize: "13px" } }, { selector: '[data-tut="reactourSecond"]', content: `Drag the signature or stamp placeholder onto the PDF to choose your desired signing location.`, position: "top", - style: { fontSize: "13px" }, + style: { fontSize: "13px" } }, { selector: '[data-tut="reactourThird"]', content: `Drag the placeholder for a recipient anywhere on the document.Remember, it will appear in the same colour as the name of the recipient for easy reference.`, position: "top", - style: { fontSize: "13px" }, + style: { fontSize: "13px" } }, { selector: '[data-tut="reactourFour"]', content: `Clicking "Send" button will share the document with all the recipients.It will also send out emails to everyone on the recipients list.`, position: "top", - style: { fontSize: "13px" }, - }, + style: { fontSize: "13px" } + } ]; //function for update TourStatus @@ -872,14 +871,14 @@ function PlaceHolderSign() { "baseUrl" )}classes/${extUserClass}/${signerUserId}`, { - TourStatus: updatedTourStatus, + TourStatus: updatedTourStatus }, { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - sessionToken: localStorage.getItem("accesstoken"), - }, + sessionToken: localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -927,7 +926,7 @@ function PlaceHolderSign() {
500 && "20px", - marginRight: pdfOriginalWidth > 500 && "20px", + marginRight: pdfOriginalWidth > 500 && "20px" }} > {/* this modal is used show alert set placeholder for all signers before send mail */} @@ -967,7 +966,7 @@ function PlaceHolderSign() {
diff --git a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js index a560a6b3a..31d4c2dd9 100644 --- a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js +++ b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js @@ -14,7 +14,7 @@ import DefaultSignature from "./component/defaultSignature"; import { getBase64FromUrl, getBase64FromIMG, - contactBookName, + contactBookName } from "../utils/Utils"; import Tour from "reactour"; import Signedby from "./component/signedby"; @@ -46,7 +46,7 @@ function EmbedPdfImage() { const [handleError, setHandleError] = useState(); const [isLoading, setIsLoading] = useState({ isLoad: true, - message: "This might take some time", + message: "This might take some time" }); const [defaultSignImg, setDefaultSignImg] = useState(); const [userObjectID, setUserObjectID] = useState(); @@ -62,9 +62,12 @@ function EmbedPdfImage() { const [noData, setNoData] = useState(false); const [contractName, setContractName] = useState(""); const [isDecline, setIsDecline] = useState({ - isDeclined: false, + isDeclined: false + }); + const [pdfLoadFail, setPdfLoadFail] = useState({ + status: false, + type: "load" }); - const [pdfLoadFail, setPdfLoadFail] = useState(false); const docId = id && id; //"F0hg0twSJH"; @@ -86,7 +89,8 @@ function EmbedPdfImage() { //aspfUo7wRl let currUserId, userObjectId; const json = await contactBookName(userPhone, "_Users"); - if (json && json.results[0]) { + + if (json !== "Error: Something went wrong!" && json && json.results[0]) { setContractName("_Users"); if (json.results[0]) { userObjectId = json.results[0].UserId.objectId; @@ -109,13 +113,13 @@ function EmbedPdfImage() { } else { setNoData(true); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } } else if (json === "Error: Something went wrong!") { const loadObj = { - isLoad: false, + isLoad: false }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); @@ -144,7 +148,7 @@ function EmbedPdfImage() { } else { setNoData(true); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } @@ -210,8 +214,8 @@ function EmbedPdfImage() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -230,27 +234,27 @@ function EmbedPdfImage() { //then show alert with completed message const alreadySign = { status: true, - mssg: "This document has already been signed!", + mssg: "This document has already been signed!" }; setIsAlreadySign(alreadySign); setPdfUrl(res[0].SignedUrl); setSignedPdfData(json.results); setCompletePdfData(res); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } else if (declined) { const currentDecline = { currnt: "another", - isDeclined: true, + isDeclined: true }; setIsDecline(currentDecline); setSignedPdfData(json.results); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } else if (currDate > expireUpdateDate) { @@ -281,7 +285,7 @@ function EmbedPdfImage() { setSignKey(key); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } @@ -301,13 +305,13 @@ function EmbedPdfImage() { setSignKey(key); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } else { @@ -338,12 +342,12 @@ function EmbedPdfImage() { if (checkAlreadyBySigner && checkAlreadyBySigner.length > 0) { const alreadySign = { status: true, - mssg: "You have successfully signed the document!", + mssg: "You have successfully signed the document!" }; setIsAlreadySign(alreadySign); setPdfUrl(res[0].SignedUrl); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } @@ -363,7 +367,7 @@ function EmbedPdfImage() { setSignKey(key); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } @@ -384,7 +388,7 @@ function EmbedPdfImage() { setSignKey(key); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } @@ -392,14 +396,14 @@ function EmbedPdfImage() { } else { setNoData(true); const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); } }) .catch((err) => { const loadObj = { - isLoad: false, + isLoad: false }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); @@ -414,8 +418,8 @@ function EmbedPdfImage() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -426,7 +430,7 @@ function EmbedPdfImage() { setDefaultSignImg(res[0].ImageURL); } const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); }) @@ -438,6 +442,10 @@ function EmbedPdfImage() { //function for get pdf page details const pageDetails = async (pdf) => { + const load = { + status: true + }; + setPdfLoadFail(load); pdf.getPage(1).then((pdfPage) => { const pageWidth = pdfPage.view[2]; @@ -462,7 +470,7 @@ function EmbedPdfImage() { } else { const loadObj = { isLoad: true, - message: "This might take some time", + message: "This might take some time" }; setIsLoading(loadObj); const url = pdfUrl @@ -474,7 +482,7 @@ function EmbedPdfImage() { // Load a PDFDocument from the existing PDF bytes const pdfDoc = await PDFDocument.load(existingPdfBytes, { - ignoreEncryption: true, + ignoreEncryption: true }); const pngUrl = xyPostion; @@ -499,7 +507,7 @@ function EmbedPdfImage() { y: page.getHeight() - 10, size: fontSize, font, - color: rgb(0.5, 0.5, 0.5), + color: rgb(0.5, 0.5, 0.5) }); } pdfBase64 = await pdfDoc.saveAsBase64({ useObjectStreams: false }); @@ -575,7 +583,7 @@ function EmbedPdfImage() { y: page.getHeight() - 10, size: fontSize, font, - color: rgb(0.5, 0.5, 0.5), + color: rgb(0.5, 0.5, 0.5) }); } for (let i = 0; i < pngUrl.length; i++) { @@ -621,11 +629,14 @@ function EmbedPdfImage() { const newWidth = window.innerWidth; const scale = isMobile ? pdfOriginalWidth / newWidth : 1; page.drawImage(img, { - x: imgUrlList[id].xPosition * scale + 50, + x: isMobile + ? imgUrlList[id].xPosition * scale + 50 + : imgUrlList[id].xPosition, + y: page.getHeight() - imgUrlList[id].yPosition * scale - imgHeight, width: imgWidth, - height: imgHeight, + height: imgHeight }); }); } @@ -674,13 +685,13 @@ function EmbedPdfImage() { Bottom: bottomY, Width: xyPosData.Width ? xyPosData.Width : 150, Height: height, - Page: pageNo, - }, + Page: pageNo + } }; } else if (xyPostion.length > 0 && xyPostion[0].pos.length > 0) { signgleSign = { pdfFile: base64Url, - docId: docId, + docId: docId }; } @@ -692,8 +703,8 @@ function EmbedPdfImage() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - sessionToken: localStorage.getItem("accesstoken"), - }, + sessionToken: localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -786,7 +797,7 @@ function EmbedPdfImage() { //function for set decline true on press decline button const declineDoc = async () => { const data = { - IsDeclined: true, + IsDeclined: true }; await axios @@ -799,8 +810,8 @@ function EmbedPdfImage() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((result) => { @@ -808,7 +819,7 @@ function EmbedPdfImage() { if (res) { const currentDecline = { currnt: "YouDeclined", - isDeclined: true, + isDeclined: true }; setIsDecline(currentDecline); } @@ -834,7 +845,7 @@ function EmbedPdfImage() { const newXypos = { pageNumber: getPageNo, - pos: addSign, + pos: addSign }; xyDefaultPos.push(newXypos); } @@ -869,14 +880,14 @@ function EmbedPdfImage() { "_appName" )}${contractName}/${signerUserId}`, { - TourStatus: updatedTourStatus, + TourStatus: updatedTourStatus }, { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - sessionToken: localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -896,20 +907,20 @@ function EmbedPdfImage() { selector: '[data-tut="reactourFirst"]', content: `You can click "Auto Sign All" to automatically sign at all the locations meant to be signed by you.Make sure that you review the document properly before you click this button.`, position: "top", - style: { fontSize: "13px" }, + style: { fontSize: "13px" } }, { selector: '[data-tut="reactourSecond"]', content: `Click any of such placeholders appearing on the document to sign.You will see the options to draw sign or upload an image once you click here.`, position: "top", - style: { fontSize: "13px" }, + style: { fontSize: "13px" } }, { selector: '[data-tut="reactourThird"]', content: `Click here to finish & download the signed document.You will also receive a copy on your email.`, position: "top", - style: { fontSize: "13px" }, - }, + style: { fontSize: "13px" } + } ]; const stepsToShow = @@ -928,6 +939,7 @@ function EmbedPdfImage() { /> ); }; + return ( {isLoading.isLoad ? ( @@ -939,7 +951,10 @@ function EmbedPdfImage() { ) : (
{/* this component used for UI interaction and show their functionality */} - {!isExpired || (!pdfLoadFail && !checkTourStatus && tourFunction())} + {pdfLoadFail.status && + !isExpired && + !checkTourStatus && + tourFunction()} {/* this component used to render all pdf pages in left side */} 500 && "20px", - marginRight: pdfOriginalWidth > 500 && "20px", + marginRight: pdfOriginalWidth > 500 && "20px" }} > {/* this modal is used for show decline alert */} @@ -982,7 +997,7 @@ function EmbedPdfImage() { <>
diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js index 9bd6b5f73..2d3314dad 100644 --- a/microfrontends/SignDocuments/src/utils/Utils.js +++ b/microfrontends/SignDocuments/src/utils/Utils.js @@ -86,7 +86,7 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { Width: newWidth, Height: nweHeight, SignUrl: image.src, - ImageType: image.imgType, + ImageType: image.imgType }; } return url; @@ -132,7 +132,7 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { Width: newWidth, Height: newHeight, SignUrl: image.src, - ImageType: image.imgType, + ImageType: image.imgType }; } return url; @@ -151,54 +151,54 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { //function for save button to save signature or image url export function onSaveSign(xyPostion, index, signKey, signatureImg) { - const updateFilter = xyPostion[index].pos.filter( - (data) => data.key === signKey && data.SignUrl - ); + // const updateFilter = xyPostion[index].pos.filter( + // (data) => data.key === signKey && data.SignUrl + // ); - if (updateFilter.length > 0) { - const getXYdata = xyPostion[index].pos; - // updateFilter[0].SignUrl = signatureImg; + let getXYdata = xyPostion[index].pos; + let getPosData = getXYdata; + // if (updateFilter.length > 0) { + // updateFilter[0].SignUrl = signatureImg; + const addSign = getPosData.map((url, ind) => { + if (url.key === signKey) { + return { + ...url, + Width: getPosData[0].Width ? getPosData[0].Width : 150, + Height: getPosData[0].Height ? getPosData[0].Height : 60, + SignUrl: signatureImg + }; + } + return url; + }); - const getPosData = getXYdata; - const addSign = getPosData.map((url, ind) => { - if (url.key === signKey) { - return { - ...url, - Width: 150, - Height: 60, - SignUrl: signatureImg, - }; - } - return url; - }); + const newUpdateUrl = xyPostion.map((obj, ind) => { + if (ind === index) { + return { ...obj, pos: addSign }; + } + return obj; + }); + return newUpdateUrl; + // } else { + // const addSign = getPosData.map((url, ind) => { + // if (url.key === signKey) { + // return { + // ...url, + // SignUrl: signatureImg, + // Width: getPosData[0].Width ? getPosData[0].Width : 150, + // Height: getPosData[0].Height ? getPosData[0].Height : 60 + // }; + // } + // return url; + // }); - const newUpdateUrl = xyPostion.map((obj, ind) => { - if (ind === index) { - return { ...obj, pos: addSign }; - } - return obj; - }); - return newUpdateUrl; - } else { - const getXYdata = xyPostion[index].pos; - - const getPosData = getXYdata; - - const addSign = getPosData.map((url, ind) => { - if (url.key === signKey) { - return { ...url, SignUrl: signatureImg, Width: 150, Height: 60 }; - } - return url; - }); - - const newUpdateUrl = xyPostion.map((obj, ind) => { - if (ind === index) { - return { ...obj, pos: addSign }; - } - return obj; - }); - return newUpdateUrl; - } + // const newUpdateUrl = xyPostion.map((obj, ind) => { + // if (ind === index) { + // return { ...obj, pos: addSign }; + // } + // return obj; + // }); + // return newUpdateUrl; + // } } //function for getting contract_User details @@ -212,8 +212,8 @@ export const contractUsers = async (objectId) => { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -239,8 +239,8 @@ export const contactBook = async (objectId) => { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -265,8 +265,8 @@ export const contactBookName = async (userPhone, className) => { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) .then((Listdata) => { @@ -278,3 +278,5 @@ export const contactBookName = async (userPhone, className) => { }); return result; }; + +