Skip to content

Commit 969071b

Browse files
Merge pull request #501 from OpenSignLabs/placeholder_sign
fix: show warning on placeholder_sign page for document already send to signers for signature
2 parents 9a51eed + 76491a7 commit 969071b

File tree

2 files changed

+75
-10
lines changed

2 files changed

+75
-10
lines changed

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ function PdfRequestFiles() {
988988
: isDecline.currnt === "YouDeclined"
989989
? "You have declined this document!"
990990
: isDecline.currnt === "another" &&
991-
"You cannot sign this document as it has been declined by one or more person(s)."
991+
"You cannot sign this document as it has been declined by one or more recipient(s)."
992992
}
993993
footerMessage={isDecline.currnt === "Sure"}
994994
declineDoc={declineDoc}

apps/OpenSign/src/pages/PlaceHolderSign.js

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ function PlaceHolderSign() {
102102
const [widgetName, setWidgetName] = useState(false);
103103
const [mailStatus, setMailStatus] = useState("");
104104
const [isCurrUser, setIsCurrUser] = useState(false);
105+
const [isAlreadyPlace, setIsAlreadyPlace] = useState({
106+
status: false,
107+
message: ""
108+
});
105109
const color = [
106110
"#93a3db",
107111
"#e6c3db",
@@ -193,15 +197,49 @@ function PlaceHolderSign() {
193197
//getting document details
194198
const documentData = await contractDocument(documentId);
195199
if (documentData && documentData.length > 0) {
196-
// const alreadyPlaceholder =
197-
// documentData[0].Placeholders && documentData[0].Placeholders;
198-
// if (alreadyPlaceholder && alreadyPlaceholder.length > 0) {
199-
// setIsAlreadyPlace(true);
200-
// }
201-
// setSignersData(documentData[0]);
202-
// setIsSelectId(0);
203-
// setSignerObjId(documentData[0].Signers[0].objectId);
204-
// setContractName(documentData[0].Signers[0].className);
200+
const alreadyPlaceholder = documentData[0]?.SignedUrl;
201+
// Check if document is sent for signing
202+
if (alreadyPlaceholder) {
203+
// Check if the document is completed
204+
const isCompleted =
205+
documentData[0].IsCompleted && documentData[0]?.IsCompleted;
206+
// Get the expiration date of the document
207+
const expireDate = documentData[0].ExpiryDate.iso;
208+
// Check if the document has been declined
209+
const declined =
210+
documentData[0].IsDeclined && documentData[0]?.IsDeclined;
211+
// Get the expiration update date in milliseconds
212+
const expireUpdateDate = new Date(expireDate).getTime();
213+
// Get the current date in milliseconds
214+
const currDate = new Date().getTime();
215+
if (isCompleted) {
216+
// If document is completed
217+
setIsAlreadyPlace({
218+
status: true,
219+
message: "This document has been signed by all Signers."
220+
});
221+
} else if (declined) {
222+
// If document has been declined
223+
setIsAlreadyPlace({
224+
status: true,
225+
message:
226+
"This document has been declined by one or more recipient(s)."
227+
});
228+
} else if (currDate > expireUpdateDate) {
229+
// If document has expired
230+
setIsAlreadyPlace({
231+
status: true,
232+
message: "This Document is no longer available."
233+
});
234+
} else {
235+
// If document is dispatched for signing
236+
setIsAlreadyPlace({
237+
status: true,
238+
message: "The document has already been dispatched for signing."
239+
});
240+
}
241+
}
242+
205243
setPdfDetails(documentData);
206244

207245
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
@@ -1752,6 +1790,33 @@ function PlaceHolderSign() {
17521790
</button>
17531791
</div>
17541792
</ModalUi>
1793+
<ModalUi
1794+
headerColor={"#dc3545"}
1795+
isOpen={isAlreadyPlace.status}
1796+
title={"Document Alert"}
1797+
showClose={false}
1798+
>
1799+
<div style={{ height: "100%", padding: 20 }}>
1800+
<p>{isAlreadyPlace.message}</p>
1801+
1802+
<div
1803+
style={{
1804+
height: "1px",
1805+
backgroundColor: "#9f9f9f",
1806+
width: "100%",
1807+
marginTop: "15px",
1808+
marginBottom: "15px"
1809+
}}
1810+
></div>
1811+
<button
1812+
onClick={() => handleRecipientSign()}
1813+
type="button"
1814+
className="finishBtn cancelBtn"
1815+
>
1816+
View
1817+
</button>
1818+
</div>
1819+
</ModalUi>
17551820
<LinkUserModal
17561821
handleAddUser={handleAddUser}
17571822
isAddUser={isAddUser}

0 commit comments

Comments
 (0)