From d6c2c66fdd51dbe02ab3db1cbaf23c9de5f3b986 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Wed, 13 Dec 2023 18:12:47 +0530 Subject: [PATCH] fix: image-upload issue in mobile view --- .../src/Component/PdfRequestFiles.js | 35 ++++++++++++++----- .../src/Component/component/renderPdf.js | 2 ++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js index 4bd54bbf9..c3b3c492a 100644 --- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js +++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js @@ -494,6 +494,7 @@ function PdfRequestFiles() { data.key === signKey && data.Width && data.Height && data.SignUrl ); let getIMGWH = calculateImgAspectRatio(imgWH); + if (updateFilter.length > 0) { const getXYdata = currentSigner[0].placeHolder[i].pos; const getPosData = getXYdata; @@ -516,11 +517,17 @@ function PdfRequestFiles() { } return obj; }); - currentSigner[0].placeHolder.splice(i, 1, newUpdateUrl[0]); + const getPlaceData = currentSigner[0].placeHolder; + getPlaceData.splice(0, getPlaceData.length, ...newUpdateUrl); + const indexofSigner = signerPos.findIndex((object) => { return object.signerObjId === signerObjectId; }); - signerPos.splice(indexofSigner, 1, currentSigner[0]); + setSignerPos((prevState) => { + const newState = [...prevState]; // Create a copy of the state + newState.splice(indexofSigner, 1, ...currentSigner); // Modify the copy + return newState; // Update the state with the modified copy + }); } else { const getXYdata = currentSigner[0].placeHolder[i].pos; @@ -546,11 +553,17 @@ function PdfRequestFiles() { return obj; }); - currentSigner[0].placeHolder.splice(i, 1, newUpdateUrl[0]); + const getPlaceData = currentSigner[0].placeHolder; + getPlaceData.splice(0, getPlaceData.length, ...newUpdateUrl); + const indexofSigner = signerPos.findIndex((object) => { return object.signerObjId === signerObjectId; }); - signerPos.splice(indexofSigner, 1, currentSigner[0]); + setSignerPos((prevState) => { + const newState = [...prevState]; // Create a copy of the state + newState.splice(indexofSigner, 1, ...currentSigner); // Modify the copy + return newState; // Update the state with the modified copy + }); } }; @@ -586,6 +599,7 @@ function PdfRequestFiles() { updateFilter = currentSigner[0].placeHolder[i].pos.filter( (data) => data.key === signKey && data.SignUrl ); + const getXYdata = currentSigner[0].placeHolder[i].pos; const getPosData = getXYdata; const posWidth = isDefaultSign @@ -633,12 +647,15 @@ function PdfRequestFiles() { } return obj; }); - let signerupdate = []; - signerupdate = signerPos.filter( - (data) => data.signerObjId !== signerObjectId + + const index = signerPos.findIndex( + (data) => data.signerObjId === signerObjectId ); - signerupdate.push(newUpdatePos[0]); - setSignerPos(signerupdate); + setSignerPos((prevState) => { + const newState = [...prevState]; // Create a copy of the state + newState.splice(index, 1, ...newUpdatePos); // Modify the copy + return newState; // Update the state with the modified copy + }); } }; diff --git a/microfrontends/SignDocuments/src/Component/component/renderPdf.js b/microfrontends/SignDocuments/src/Component/component/renderPdf.js index 629bc0a66..01993a387 100644 --- a/microfrontends/SignDocuments/src/Component/component/renderPdf.js +++ b/microfrontends/SignDocuments/src/Component/component/renderPdf.js @@ -377,6 +377,7 @@ function RenderPdf({ onClick={() => { setIsSignPad(true); setSignKey(pos.key); + setIsStamp(false); }} > @@ -794,6 +795,7 @@ function RenderPdf({ onClick={() => { setIsSignPad(true); setSignKey(pos.key); + setIsStamp(false); }} >