diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
index c3b3c492a..6cda177de 100644
--- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
+++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
@@ -21,8 +21,9 @@ import {
embedDocId,
pdfNewWidthFun,
signPdfFun,
- calculateImgAspectRatio,
- onImageSelect
+ onImageSelect,
+ onSaveSign,
+ onSaveImage
} from "../utils/Utils";
import Loader from "./component/loader";
import HandleError from "./component/HandleError";
@@ -482,181 +483,99 @@ function PdfRequestFiles() {
}
};
//function for upload stamp image
- const onSaveImage = () => {
+ const saveImage = () => {
+ //get current signers placeholder position data
const currentSigner = signerPos.filter(
(data) => data.signerObjId === signerObjectId
);
- const i = currentSigner[0].placeHolder.findIndex((object) => {
+ //get current pagenumber placeholder index
+ const getIndex = currentSigner[0].placeHolder.findIndex((object) => {
return object.pageNumber === pageNumber;
});
- const updateFilter = currentSigner[0].placeHolder[i].pos.filter(
- (data) =>
- data.key === signKey && data.Width && data.Height && data.SignUrl
+ //get current signer placeholder position data
+ const placeholderPosition = currentSigner[0].placeHolder;
+ //function of save image and get updated position with image url
+ const getUpdatePosition = onSaveImage(
+ placeholderPosition,
+ getIndex,
+ signKey,
+ imgWH,
+ image
);
- let getIMGWH = calculateImgAspectRatio(imgWH);
- if (updateFilter.length > 0) {
- const getXYdata = currentSigner[0].placeHolder[i].pos;
- const getPosData = getXYdata;
- const addSign = getPosData.map((url, ind) => {
- if (url.key === signKey) {
- return {
- ...url,
- Width: getIMGWH.newWidth,
- Height: getIMGWH.newHeight,
- SignUrl: image.src,
- ImageType: image.imgType
- };
- }
- return url;
- });
-
- const newUpdateUrl = currentSigner[0].placeHolder.map((obj, ind) => {
- if (ind === i) {
- return { ...obj, pos: addSign };
- }
- return obj;
- });
- const getPlaceData = currentSigner[0].placeHolder;
- getPlaceData.splice(0, getPlaceData.length, ...newUpdateUrl);
-
- const indexofSigner = signerPos.findIndex((object) => {
- return object.signerObjId === signerObjectId;
- });
- 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;
-
- const getPosData = getXYdata;
-
- const addSign = getPosData.map((url, ind) => {
- if (url.key === signKey) {
- return {
- ...url,
- Width: getIMGWH.newWidth,
- Height: getIMGWH.newHeight,
- SignUrl: image.src,
- ImageType: image.imgType
- };
- }
- return url;
- });
-
- const newUpdateUrl = currentSigner[0].placeHolder.map((obj, ind) => {
- if (ind === i) {
- return { ...obj, pos: addSign };
- }
- return obj;
- });
-
- const getPlaceData = currentSigner[0].placeHolder;
- getPlaceData.splice(0, getPlaceData.length, ...newUpdateUrl);
-
- const indexofSigner = signerPos.findIndex((object) => {
- return object.signerObjId === signerObjectId;
- });
- 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
- });
- }
+ //replace updated placeholder position with old data
+ placeholderPosition.splice(
+ 0,
+ placeholderPosition.length,
+ ...getUpdatePosition
+ );
+ //get current signers placeholder position data index number in array
+ const indexofSigner = signerPos.findIndex((object) => {
+ return object.signerObjId === signerObjectId;
+ });
+ //update current signers data with new placeholder position array data
+ 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
+ });
};
//function for save button to save signature or image url
- const onSaveSign = (isDefaultSign) => {
+ const saveSign = (isDefaultSign) => {
const signatureImg = isDefaultSign ? defaultSignImg : signature;
- const isSign = true;
- let getIMGWH;
+ let imgWH = { width: "", height: "" };
setIsSignPad(false);
setIsImageSelect(false);
setImage();
+
+ //get current signers placeholder position data
+ const currentSigner = signerPos.filter(
+ (data) => data.signerObjId === signerObjectId
+ );
+ //get current pagenumber placeholder index
+ const getIndex = currentSigner[0].placeHolder.findIndex((object) => {
+ return object.pageNumber === pageNumber;
+ });
+
+ //set default signature image width and height
if (isDefaultSign) {
const img = new Image();
img.src = defaultSignImg;
if (img.complete) {
- let imgWH = {
+ imgWH = {
width: img.width,
height: img.height
};
- getIMGWH = calculateImgAspectRatio(imgWH);
}
}
- const currentSigner = signerPos.filter(
- (data) => data.signerObjId === signerObjectId
+ //get current signer placeholder position data
+ const placeholderPosition = currentSigner[0].placeHolder;
+ //function of save signature image and get updated position with signature image url
+ const getUpdatePosition = onSaveSign(
+ placeholderPosition,
+ getIndex,
+ signKey,
+ signatureImg,
+ imgWH,
+ isDefaultSign
);
- const i = currentSigner[0].placeHolder.findIndex((object) => {
- return object.pageNumber === pageNumber;
+ const updateSignerData = currentSigner.map((obj, ind) => {
+ if (obj.signerObjId === signerObjectId) {
+ return { ...obj, placeHolder: getUpdatePosition };
+ }
+ return obj;
});
- let updateFilter;
-
- updateFilter = currentSigner[0].placeHolder[i].pos.filter(
- (data) => data.key === signKey && data.SignUrl
+ const index = signerPos.findIndex(
+ (data) => data.signerObjId === signerObjectId
);
-
- const getXYdata = currentSigner[0].placeHolder[i].pos;
- const getPosData = getXYdata;
- const posWidth = isDefaultSign
- ? getIMGWH.newWidth
- : isSign && getPosData[0].ImageType
- ? 150
- : getPosData[0].Width
- ? getPosData[0].Width
- : 150;
- const posHidth = isDefaultSign
- ? getIMGWH.newHeight
- : isSign && getPosData[0].ImageType
- ? 60
- : getPosData[0].Height
- ? getPosData[0].Height
- : 60;
- if (updateFilter.length > 0) {
- updateFilter[0].SignUrl = signatureImg;
- updateFilter[0].Width = posWidth;
- updateFilter[0].Height = posHidth;
- } else {
- const addSign = getPosData.map((url, ind) => {
- if (url.key === signKey) {
- return {
- ...url,
- SignUrl: signatureImg,
- Width: posWidth,
- Height: posHidth,
- ImageType: "sign"
- };
- }
- return url;
- });
-
- const newUpdateUrl = currentSigner[0].placeHolder.map((obj, ind) => {
- if (obj.pageNumber === pageNumber) {
- return { ...obj, pos: addSign };
- }
- return obj;
- });
-
- const newUpdatePos = currentSigner.map((obj, ind) => {
- if (obj.signerObjId === signerObjectId) {
- return { ...obj, placeHolder: newUpdateUrl };
- }
- return obj;
- });
-
- const index = signerPos.findIndex(
- (data) => data.signerObjId === signerObjectId
- );
- 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
- });
- }
+ setSignerPos((prevState) => {
+ const newState = [...prevState];
+ newState.splice(index, 1, ...updateSignerData);
+ return newState;
+ });
};
const checkSignerBackColor = (obj) => {
@@ -782,6 +701,7 @@ function PdfRequestFiles() {
allPages={allPages}
setAllPages={setAllPages}
setPageNumber={setPageNumber}
+ pageNumber={pageNumber}
/>
{/* pdf render view */}
@@ -831,8 +751,8 @@ function PdfRequestFiles() {
onImageChange={onImageChange}
setSignature={setSignature}
image={image}
- onSaveImage={onSaveImage}
- onSaveSign={onSaveSign}
+ onSaveImage={saveImage}
+ onSaveSign={saveSign}
defaultSign={defaultSignImg}
/>
{/* pdf header which contain funish back button */}
diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
index e1fad20b6..c2a363590 100644
--- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
+++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
@@ -23,7 +23,9 @@ import {
multiSignEmbed,
pdfNewWidthFun,
addDefaultSignatureImg,
- onImageSelect
+ onImageSelect,
+ placeholderHeight,
+ placeholderWidth
} from "../utils/Utils";
import { useParams } from "react-router-dom";
import Tour from "reactour";
@@ -36,6 +38,7 @@ import RenderPdf from "./component/renderPdf";
import { contractUsers, contactBook, urlValidator } from "../utils/Utils";
import { modalAlign } from "../utils/Utils";
import AlertComponent from "./component/alertComponent";
+import PlaceholderCopy from "./component/PlaceholderCopy";
//For signYourself inProgress section signer can add sign and complete doc sign.
function SignYourSelf() {
@@ -79,6 +82,7 @@ function SignYourSelf() {
const [noData, setNoData] = useState(false);
const [contractName, setContractName] = useState("");
const [containerWH, setContainerWH] = useState({});
+ const [isPageCopy, setIsPageCopy] = useState(false);
const [showAlreadySignDoc, setShowAlreadySignDoc] = useState({
status: false
});
@@ -102,7 +106,6 @@ function SignYourSelf() {
const [{ isDragSign }, dragSignature] = useDrag({
type: "BOX",
-
item: {
type: "BOX",
id: 1,
@@ -115,7 +118,6 @@ function SignYourSelf() {
const [{ isDragStamp }, dragStamp] = useDrag({
type: "BOX",
-
item: {
type: "BOX",
id: 2,
@@ -140,7 +142,6 @@ function SignYourSelf() {
const [{ isDragStampSS }, dragStampSS] = useDrag({
type: "BOX",
-
item: {
type: "BOX",
id: 4,
@@ -329,7 +330,6 @@ function SignYourSelf() {
isDrag: false,
key: key,
isStamp: monitor,
-
yBottom: window.innerHeight / 2 - 60
};
@@ -516,22 +516,31 @@ function SignYourSelf() {
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
if (xyPostion.length === 1 && xyPostion[0].pos.length === 1) {
+ const xPos = () => {
+ const resizePos = xyPosData.xPosition;
+ if (isMobile) {
+ return resizePos * scale;
+ } else {
+ return resizePos;
+ }
+ };
const height = xyPosData.Height ? xyPosData.Height : 60;
+ const resizePos = xyPosData.yBottom;
const bottomY = xyPosData.isDrag
- ? xyPosData.yBottom * scale - height * scale
+ ? resizePos * scale - height * scale
: xyPosData.firstYPos
- ? xyPosData.yBottom * scale - height * scale + xyPosData.firstYPos
- : xyPosData.yBottom * scale - height * scale;
+ ? resizePos * scale - height * scale + xyPosData.firstYPos
+ : resizePos * scale - height * scale;
singleSign = {
pdfFile: pdfBase64Url,
docId: documentId,
sign: {
Base64: base64Url,
- Left: isMobile ? xyPosData.xPosition * scale : xyPosData.xPosition,
+ Left: xPos(),
Bottom: bottomY,
- Width: xyPosData.Width ? xyPosData.Width * scale : 150 * scale,
- Height: height * scale,
+ Width: placeholderWidth(xyPosData, scale),
+ Height: placeholderHeight(xyPosData, scale),
Page: pageNo
}
};
@@ -650,7 +659,7 @@ function SignYourSelf() {
//function for save button to save signature or image url
const saveSign = (isDefaultSign) => {
const signatureImg = isDefaultSign ? defaultSignImg : signature;
- const signFlag = true;
+
let imgWH = { width: "", height: "" };
setIsSignPad(false);
setIsImageSelect(false);
@@ -672,8 +681,7 @@ function SignYourSelf() {
signKey,
signatureImg,
imgWH,
- isDefaultSign,
- signFlag
+ isDefaultSign
);
setXyPostion(getUpdatePosition);
@@ -826,6 +834,7 @@ function SignYourSelf() {
setAllPages={setAllPages}
setPageNumber={setPageNumber}
setSignBtnPosition={setSignBtnPosition}
+ pageNumber={pageNumber}
/>
{/* pdf render view */}
@@ -881,6 +890,15 @@ function SignYourSelf() {
)}
+