Skip to content

Commit 72431b2

Browse files
fix: redirect wrong route of draft docment issue in openSign-drive
1 parent 3ca48e5 commit 72431b2

File tree

5 files changed

+132
-135
lines changed

5 files changed

+132
-135
lines changed

microfrontends/SignDocuments/src/Component/DraftDocument.js

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,65 +47,51 @@ function DraftDocument() {
4747
//check document type and render on signyour self and placeholder route
4848
const handleDraftDoc = () => {
4949
const data = pdfDetails[0];
50-
const checkSignerExist =
51-
pdfDetails[0] && pdfDetails[0].Signers && pdfDetails[0].Signers;
52-
const isPlaceholder =
53-
pdfDetails[0].Placeholders && pdfDetails[0].Placeholders;
54-
const isDecline = data.IsDeclined && data.IsDeclined;
55-
const signUrl = data.SignedUrl && data.SignedUrl;
56-
const expireDate =
57-
pdfDetails[0] &&
58-
pdfDetails[0].ExpiryDate.iso &&
59-
pdfDetails[0].ExpiryDate.iso;
50+
const hostUrl = getHostUrl();
51+
const expireDate = data.ExpiryDate.iso;
6052
const expireUpdateDate = new Date(expireDate).getTime();
6153
const currDate = new Date().getTime();
62-
const hostUrl = getHostUrl();
54+
const signerExist = data.Signers && data.Signers;
55+
const signUrl = data.SignedUrl && data.SignedUrl;
56+
const isDecline = data.IsDeclined && data.IsDeclined;
57+
const isPlaceholder = data.Placeholders && data.Placeholders;
6358

64-
//checking document is completed and signer exist then navigate to pdfRequestFiles file
65-
if (data.IsCompleted && checkSignerExist) {
66-
navigate(`${hostUrl}pdfRequestFiles`);
59+
let isExpire = false;
60+
if (currDate > expireUpdateDate) {
61+
isExpire = true;
6762
}
68-
//checking document is completed and signer does not exist then navigate to recipientSignPdf file
69-
else if (data.IsCompleted && !checkSignerExist) {
70-
navigate(`${hostUrl}signaturePdf`);
63+
//checking if document has completed
64+
if (data?.IsCompleted && signerExist?.length > 0) {
65+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
66+
} else if (data?.IsCompleted && signerExist?.length === 0) {
67+
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
7168
}
72-
//checking document is declined by someone then navigate to pdfRequestFiles file
69+
//checking if document has declined by someone
7370
else if (isDecline) {
74-
navigate(`${hostUrl}pdfRequestFiles`);
75-
}
76-
//checking document has expired and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file
77-
//draft type request sign document
78-
else if (
79-
currDate > expireUpdateDate &&
80-
checkSignerExist &&
81-
!isPlaceholder
82-
) {
83-
navigate(`${hostUrl}placeHolderSign`);
84-
}
85-
//checking document has expired and signers does not exist and document not signed yet then navigate to pdfRequestFiles file
86-
//draft type signyouselfdocument
87-
else if (
88-
currDate > expireUpdateDate &&
89-
!checkSignerExist &&
90-
!isPlaceholder &&
71+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
72+
//checking draft type document
73+
} else if (
74+
isExpire &&
75+
signerExist?.length === 0 &&
76+
isPlaceholder?.length === 0 &&
9177
!signUrl
9278
) {
93-
// window.location.hash = `/signaturePdf`;
94-
navigate(`${hostUrl}signaturePdf`);
95-
}
96-
//checking document has expired and signers exist and document then navigate to pdfRequestFiles file
97-
else if (currDate > expireUpdateDate) {
98-
// window.location.hash = `/pdfRequestFiles`;
99-
navigate(`${hostUrl}pdfRequestFiles`);
79+
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
80+
} else if (
81+
(isExpire || !isExpire) &&
82+
isPlaceholder?.length > 0 &&
83+
signerExist?.length > 0
84+
) {
85+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
86+
} else if (signerExist?.length > 0 && isPlaceholder?.length === 0) {
87+
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
88+
//checking draft type document
89+
} else if (signerExist?.length === 0 && isPlaceholder?.length > 0) {
90+
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
10091
}
101-
//checking document has expired not been expired yet and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file
102-
//draft type request sign document
103-
else if (!signUrl && checkSignerExist) {
104-
navigate(`${hostUrl}placeHolderSign`);
105-
// window.location.hash = `/placeHolderSign`;
106-
} else {
107-
// window.location.hash = `/signaturePdf/`;
108-
navigate(`${hostUrl}signaturePdf`);
92+
//checking document is draft and signyourself type then user can sign document
93+
else {
94+
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
10995
}
11096
};
11197

microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function PdfFileComponent({
2828
const [isOpenMoveModal, setIsOpenMoveModal] = useState(false);
2929
const [selectDoc, setSelectDoc] = useState();
3030
const [isDeleteDoc, setIsDeleteDoc] = useState(false);
31-
const contextMenu = ["Download", "Rename", "Delete", "Move"];
31+
const contextMenu = ["Download", "Rename", "Move", "Delete"];
3232
const navigate = useNavigate();
3333

3434
//to focus input box on press rename to change doc name
@@ -113,56 +113,45 @@ function PdfFileComponent({
113113
const signUrl = data.SignedUrl && data.SignedUrl;
114114
const isDecline = data.IsDeclined && data.IsDeclined;
115115
const isPlaceholder = data.Placeholders && data.Placeholders;
116-
//checking and navigate to signyouself page
117-
const checkPlaceHolder = data.Placeholders;
116+
117+
let isExpire = false;
118+
if (currDate > expireUpdateDate) {
119+
isExpire = true;
120+
}
118121
//checking if document has completed
119-
if (data.IsCompleted && signerExist) {
122+
if (data?.IsCompleted && signerExist?.length > 0) {
120123
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
121124

122125
// window.location.hash = `/pdfRequestFiles/${data.objectId}`;
123-
} else if (data.IsCompleted && !signerExist) {
126+
} else if (data?.IsCompleted && signerExist?.length === 0) {
124127
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
125128
}
126129
//checking if document has declined by someone
127130
else if (isDecline) {
128131
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
129-
// window.location.hash = `/pdfRequestFiles/${data.objectId}`;
130-
} else if (currDate > expireUpdateDate && signerExist && !isPlaceholder) {
131-
// window.location.hash = `/placeHolderSign/${data.objectId}`;
132-
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
132+
//checking draft type document
133133
} else if (
134-
currDate > expireUpdateDate &&
135-
!signerExist &&
136-
!isPlaceholder &&
134+
isExpire &&
135+
signerExist?.length === 0 &&
136+
isPlaceholder?.length === 0 &&
137137
!signUrl
138138
) {
139139
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
140-
// window.location.hash = `/signaturePdf/${data.objectId}`;
141-
}
142-
//checking if document has expired
143-
else if (currDate > expireUpdateDate) {
144-
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
145-
// window.location.hash = `/pdfRequestFiles/${data.objectId}`;
146-
} //checking if document is draft signers type and signers placeholder does not placed yet
147-
else if (!signUrl && signerExist) {
148-
// window.location.hash = `/placeHolderSign/${data.objectId}`;
149-
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
150-
}
151-
//checking if document is request type and signers placeholder exist and does not completed yet
152-
//then user can check progress of document and sign also
153-
else if (
154-
checkPlaceHolder &&
155-
checkPlaceHolder.length > 0 &&
156-
!data.IsCompleted
140+
} else if (
141+
(isExpire || !isExpire) &&
142+
isPlaceholder?.length > 0 &&
143+
signerExist?.length > 0
157144
) {
158145
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
159-
// window.location.hash = `/pdfRequestFiles/${data.objectId}`;
146+
} else if (signerExist?.length > 0 && isPlaceholder?.length === 0) {
147+
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
148+
//checking draft type document
149+
} else if (signerExist?.length === 0 && isPlaceholder?.length > 0) {
150+
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
160151
}
161152
//checking document is draft and signyourself type then user can sign document
162153
else {
163154
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
164-
// navigate(`/signaturePdf/${data.objectId}`);
165-
// window.location.hash = `/signaturePdf/${data.objectId}`;
166155
}
167156
};
168157

@@ -189,6 +178,7 @@ function PdfFileComponent({
189178
};
190179
//function for delete document
191180
const handleDeleteDocument = async (docData) => {
181+
setIsDeleteDoc(false);
192182
const docId = docData.objectId;
193183
const data = {
194184
IsArchive: true
@@ -302,7 +292,6 @@ function PdfFileComponent({
302292
status,
303293
isDecline,
304294
signerExist,
305-
isExpire,
306295
isComplete,
307296
signUrl,
308297
isPlaceholder;
@@ -317,36 +306,55 @@ function PdfFileComponent({
317306
signUrl = data.SignedUrl && data.SignedUrl;
318307
const expireUpdateDate = new Date(expireDate).getTime();
319308
const currDate = new Date().getTime();
320-
309+
let isExpire = false;
321310
if (currDate > expireUpdateDate) {
322311
isExpire = true;
323-
} else {
324-
isExpire = false;
325312
}
313+
326314
if (isComplete) {
327315
status = "Completed";
328316
} else if (isDecline) {
329317
status = "Declined";
330-
} else if (isExpire && !isPlaceholder && signerExist) {
331-
// status = "Expired";
318+
} else if (
319+
!isExpire &&
320+
isPlaceholder?.length === 0 &&
321+
signerExist?.length > 0
322+
) {
332323
status = "Draft";
333-
} else if (isExpire && !isPlaceholder && !signerExist && !signUrl) {
334-
// status = "Expired";
324+
} else if (
325+
!isExpire &&
326+
isPlaceholder?.length > 0 &&
327+
signerExist?.length === 0
328+
) {
329+
status = "Draft";
330+
} else if (
331+
!isExpire &&
332+
isPlaceholder?.length === 0 &&
333+
signerExist?.length > 0 &&
334+
!signUrl
335+
) {
335336
status = "Draft";
336337
} else if (isExpire) {
337338
status = "Expired";
338339
} else if (!signUrl) {
339340
status = "Draft";
340341
} else {
341-
status = "InComplete";
342+
status = "In Progress";
342343
}
343344
}
344345

345346
const signersName = () => {
346347
const getSignersName = signerExist.map((data) => data.Name);
347348
const signerName = getSignersName.join(",");
348349

349-
return <span className="statusSpan">{signerName} </span>;
350+
return (
351+
<span
352+
className="statusSpan"
353+
style={{ width: "90%", wordWrap: "break-word" }}
354+
>
355+
{signerName}{" "}
356+
</span>
357+
);
350358
};
351359
return listType === "table" ? (
352360
data.Type === "Folder" ? (
@@ -598,7 +606,7 @@ function PdfFileComponent({
598606
<i className="fa fa-file"></i>
599607
</div>
600608
) : (
601-
status === "InComplete" && (
609+
status === "In Progress" && (
602610
<div className="status-badge in-progress">
603611
<i className="fa fa-paper-plane"></i>
604612
</div>
@@ -646,9 +654,11 @@ function PdfFileComponent({
646654
{signerExist && (
647655
<>
648656
<strong style={{ fontSize: "13px" }}>Signers: </strong>
657+
{/* <span className="statusSpan">kjefjjnejkfnkbjs bbfjkdsbjbfjkbjk kscbjkbjkb</span> */}
649658
{signersName()}
650659
</>
651660
)}
661+
652662
<HoverCard.Arrow className="HoverCardArrow" />
653663
</HoverCard.Content>
654664
</HoverCard.Portal>
@@ -732,22 +742,21 @@ function PdfFileComponent({
732742
color: "white"
733743
}}
734744
type="button"
735-
className="docDeleteBtn"
745+
className="finishBtn"
736746
>
737-
YES
747+
Yes
738748
</button>
739749
<button
740750
onClick={() => {
741751
setIsDeleteDoc(false);
742752
}}
743753
style={{
744-
background: "rgb(24 138 226)",
745-
marginLeft: "10px"
754+
color: "black"
746755
}}
747756
type="button"
748-
className="docDeleteBtn"
757+
className="finishBtn"
749758
>
750-
NO
759+
No
751760
</button>
752761
</div>
753762
</ModalUi>

microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ a {
396396
will-change: transform, opacity;
397397
text-align: center;
398398
align-items: center;
399+
399400
}
400401

401402
.HoverCardContent[data-side='top'] {

microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,20 +403,19 @@ function PdfFile() {
403403
background: themeColor()
404404
}}
405405
type="button"
406-
className="docDeleteBtn"
406+
className="finishBtn"
407407
>
408-
ADD
408+
Add
409409
</button>
410410
<button
411-
type="submit"
412411
style={{
413-
background: "rgb(24 138 226)",
414-
marginLeft: "10px"
412+
color: "black"
415413
}}
416-
className="docDeleteBtn"
414+
type="button"
415+
className="finishBtn"
417416
onClick={() => setIsFolder(false)}
418417
>
419-
CLOSE
418+
Close
420419
</button>
421420
</div>
422421
</div>

0 commit comments

Comments
 (0)