Skip to content

Commit 411941d

Browse files
fix: horizontal pdf or large size pdf's scrollbar issue in signyourself and placeholder flow
1 parent 3c54f22 commit 411941d

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

microfrontends/SignDocuments/src/Component/PdfRequestFiles.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
getBase64FromUrl,
1919
urlValidator,
2020
multiSignEmbed,
21-
embedDocId
21+
embedDocId,
22+
pdfNewWidthFun
2223
} from "../utils/Utils";
2324
import Loader from "./component/loader";
2425
import HandleError from "./component/HandleError";
@@ -92,19 +93,14 @@ function PdfRequestFiles() {
9293
const jsonSender = JSON.parse(senderUser);
9394

9495
useEffect(() => {
95-
const clientWidth = window.innerWidth;
96-
const value = docId ? 80 : 30;
97-
const pdfWidth = clientWidth - 160 - 200 - value;
98-
99-
//160 is width of left side, 200 is width of right side component and 50 is space of middle compoent
100-
//pdf from left and right component
101-
setPdfNewWidth(pdfWidth);
10296
if (documentId) {
10397
getDocumentDetails();
10498
}
10599
}, []);
106100
useEffect(() => {
107101
if (divRef.current) {
102+
const pdfWidth = pdfNewWidthFun(divRef);
103+
setPdfNewWidth(pdfWidth);
108104
setContainerWH({
109105
width: divRef.current.offsetWidth,
110106
height: divRef.current.offsetHeight

microfrontends/SignDocuments/src/Component/SignYourselfPdf.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
contractDocument,
2121
getBase64FromIMG,
2222
embedDocId,
23-
multiSignEmbed
23+
multiSignEmbed,
24+
pdfNewWidthFun
2425
} from "../utils/Utils";
2526
import { useParams } from "react-router-dom";
2627
import Tour from "reactour";
@@ -81,7 +82,7 @@ function SignYourSelf() {
8182
status: false,
8283
type: "load"
8384
});
84-
85+
const divRef = useRef(null);
8586
const nodeRef = useRef(null);
8687
const [{ isOver }, drop] = useDrop({
8788
accept: "BOX",
@@ -168,17 +169,21 @@ function SignYourSelf() {
168169
const jsonSender = JSON.parse(senderUser);
169170

170171
useEffect(() => {
171-
const clientWidth = window.innerWidth;
172-
const value = docId ? 80 : 80;
173-
const pdfWidth = clientWidth - 160 - 200 - value;
174-
//160 is width of left side, 200 is width of right side component and 50 is space of middle compoent
175-
//pdf from left and right component
176-
setPdfNewWidth(pdfWidth);
177172
if (documentId) {
178173
getDocumentDetails(true);
179174
}
180175
}, []);
181176

177+
useEffect(() => {
178+
if (divRef.current) {
179+
const pdfWidth = pdfNewWidthFun(divRef);
180+
setPdfNewWidth(pdfWidth);
181+
if (documentId) {
182+
getDocumentDetails();
183+
}
184+
}
185+
}, [divRef.current]);
186+
182187
//function for get document details for perticular signer with signer'object id
183188
const getDocumentDetails = async (showComplete) => {
184189
//getting document details
@@ -188,18 +193,19 @@ function SignYourSelf() {
188193
setPdfDetails(documentData);
189194
const isCompleted =
190195
documentData[0].IsCompleted && documentData[0].IsCompleted;
191-
if (isCompleted && showComplete) {
196+
if (isCompleted) {
192197
const docStatus = {
193198
isCompleted: isCompleted
194199
};
195-
196200
setDocumentStatus(docStatus);
201+
setPdfUrl(documentData[0].SignedUrl);
197202
const alreadySign = {
198203
status: true,
199204
mssg: "You have successfully signed the document!"
200205
};
201-
setShowAlreadySignDoc(alreadySign);
202-
setPdfUrl(documentData[0].SignedUrl);
206+
if (showComplete) {
207+
setShowAlreadySignDoc(alreadySign);
208+
}
203209
}
204210
} else if (
205211
documentData === "Error: Something went wrong!" ||
@@ -874,7 +880,7 @@ function SignYourSelf() {
874880
) : noData ? (
875881
<Nodata />
876882
) : (
877-
<div className="signatureContainer">
883+
<div className="signatureContainer" ref={divRef}>
878884
{/* this component used for UI interaction and show their functionality */}
879885
{pdfLoadFail && !checkTourStatus && (
880886
<Tour

microfrontends/SignDocuments/src/Component/placeHolderSign.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Nodata from "./component/Nodata";
1818
import SignerListPlace from "./component/signerListPlace";
1919
import Header from "./component/header";
2020
import {
21-
contactBook,
21+
pdfNewWidthFun,
2222
contractDocument,
2323
contractUsers,
2424
getHostUrl
@@ -36,13 +36,10 @@ function PlaceHolderSign() {
3636
const [pageNumber, setPageNumber] = useState(1);
3737
const [signBtnPosition, setSignBtnPosition] = useState([]);
3838
const [xySignature, setXYSignature] = useState({});
39-
const signRef = useRef(null);
40-
const dragRef = useRef(null);
4139
const [dragKey, setDragKey] = useState();
4240
const [signersdata, setSignersData] = useState();
4341
const [signerObjId, setSignerObjId] = useState();
4442
const [signerPos, setSignerPos] = useState([]);
45-
4643
const [isSelectListId, setIsSelectId] = useState();
4744
const [isSendAlert, setIsSendAlert] = useState({});
4845
const [isSend, setIsSend] = useState(false);
@@ -61,6 +58,9 @@ function PlaceHolderSign() {
6158
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
6259
const [contractName, setContractName] = useState("");
6360
const { docId } = useParams();
61+
const signRef = useRef(null);
62+
const dragRef = useRef(null);
63+
const divRef = useRef(null);
6464
const [isShowEmail, setIsShowEmail] = useState(false);
6565
const [selectedEmail, setSelectedEmail] = useState(false);
6666
const [pdfLoadFail, setPdfLoadFail] = useState({
@@ -161,17 +161,17 @@ function PlaceHolderSign() {
161161
const jsonSender = JSON.parse(senderUser);
162162

163163
useEffect(() => {
164-
const clientWidth = window.innerWidth;
165-
const value = docId ? 80 : 30;
166-
const pdfWidth = clientWidth - 160 - 200 - value;
167-
//160 is width of left side, 200 is width of right side component and 50 is space of middle compoent
168-
//pdf from left and right component
169-
setPdfNewWidth(pdfWidth);
170164
if (documentId) {
171165
getDocumentDetails();
172166
}
173167
}, []);
174168

169+
useEffect(() => {
170+
if (divRef.current) {
171+
const pdfWidth = pdfNewWidthFun(divRef);
172+
setPdfNewWidth(pdfWidth);
173+
}
174+
}, [divRef.current]);
175175
//function for get document details
176176
const getDocumentDetails = async () => {
177177
//getting document details
@@ -833,7 +833,7 @@ function PlaceHolderSign() {
833833
) : noData ? (
834834
<Nodata />
835835
) : (
836-
<div className="signatureContainer">
836+
<div className="signatureContainer" ref={divRef}>
837837
{/* this component used for UI interaction and show their functionality */}
838838
{!checkTourStatus && (
839839
//this tour component used in your html component where you want to put

microfrontends/SignDocuments/src/Component/recipientSignPdf.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import DefaultSignature from "./component/defaultSignature";
1414
import {
1515
getBase64FromUrl,
1616
getBase64FromIMG,
17-
contactBookName,
17+
pdfNewWidthFun,
1818
convertPNGtoJPEG,
1919
contractUsers,
2020
contactBook,
@@ -94,15 +94,12 @@ function EmbedPdfImage() {
9494
//check isGuestSigner is present in local if yes than handle login flow header in mobile view
9595
const isGuestSigner = localStorage.getItem("isGuestSigner");
9696
useEffect(() => {
97-
const clientWidth = window.innerWidth;
98-
const pdfWidth = clientWidth - 160 - 220 - 30;
99-
//160 is width of left side, 200 is width of right side component and 50 is space of middle compoent
100-
//pdf from left and right component
101-
setPdfNewWidth(pdfWidth);
10297
getDocumentDetails();
10398
}, []);
10499
useEffect(() => {
105100
if (divRef.current) {
101+
const pdfWidth = pdfNewWidthFun(divRef);
102+
setPdfNewWidth(pdfWidth);
106103
setContainerWH({
107104
width: divRef.current.offsetWidth,
108105
height: divRef.current.offsetHeight

microfrontends/SignDocuments/src/utils/Utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,10 @@ export const embedDocId = async (pdfDoc, documentId, allPages) => {
479479
});
480480
}
481481
};
482+
483+
export const pdfNewWidthFun = (divRef) => {
484+
const clientWidth = divRef.current.offsetWidth;
485+
const pdfWidth = clientWidth - 160 - 200;
486+
//160 is width of left side, 200 is width of right side component
487+
return pdfWidth;
488+
};

0 commit comments

Comments
 (0)