mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-30 05:24:56 +02:00
Merge branch 'staging' into transparent-img
This commit is contained in:
@@ -16,6 +16,10 @@ import {
|
||||
getBase64FromIMG,
|
||||
contactBookName,
|
||||
convertPNGtoJPEG
|
||||
contractUsers,
|
||||
contactBook,
|
||||
contractDocument,
|
||||
urlValidator
|
||||
} from "../utils/Utils";
|
||||
import Tour from "reactour";
|
||||
import Signedby from "./component/signedby";
|
||||
@@ -26,6 +30,7 @@ import Nodata from "./component/Nodata";
|
||||
import Header from "./component/header";
|
||||
import RenderPdf from "./component/renderPdf";
|
||||
import CustomModal from "./component/CustomModal";
|
||||
import { modalAlign } from "../utils/Utils";
|
||||
function EmbedPdfImage() {
|
||||
const { id, contactBookId } = useParams();
|
||||
const [isSignPad, setIsSignPad] = useState(false);
|
||||
@@ -75,6 +80,15 @@ function EmbedPdfImage() {
|
||||
return object.pageNumber === pageNumber;
|
||||
});
|
||||
const divRef = useRef(null);
|
||||
const senderUser = localStorage.getItem(
|
||||
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||
)
|
||||
? localStorage.getItem(
|
||||
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||
)
|
||||
: `${localStorage.getItem("UserInformation")}` &&
|
||||
`${localStorage.getItem("UserInformation")}`;
|
||||
const jsonSender = JSON.parse(senderUser);
|
||||
//check isGuestSigner is present in local if yes than handle login flow header in mobile view
|
||||
const isGuestSigner = localStorage.getItem("isGuestSigner");
|
||||
useEffect(() => {
|
||||
@@ -97,33 +111,26 @@ function EmbedPdfImage() {
|
||||
//function for get document details for perticular signer with signer'object id
|
||||
const getDocumentDetails = async () => {
|
||||
let currUserId, userObjectId;
|
||||
const json = await contactBookName(contactBookId, "_Contactbook");
|
||||
if (json !== "Error: Something went wrong!" && json && json.results[0]) {
|
||||
//getting contracts_contactBook details
|
||||
const json = await contactBook(contactBookId);
|
||||
if (json && json.length > 0) {
|
||||
setContractName("_Contactbook");
|
||||
if (json.results[0]) {
|
||||
userObjectId = json.results[0].UserId.objectId;
|
||||
setUserObjectID(userObjectId);
|
||||
currUserId = json.results[0].objectId;
|
||||
|
||||
setSignerUserId(currUserId);
|
||||
const tourstatus =
|
||||
json.results[0].TourStatus && json.results[0].TourStatus;
|
||||
userObjectId = json[0].UserId.objectId;
|
||||
setUserObjectID(userObjectId);
|
||||
currUserId = json[0].objectId;
|
||||
|
||||
if (tourstatus && tourstatus.length > 0) {
|
||||
setTourStatus(tourstatus);
|
||||
const checkTourRecipients = tourstatus.filter(
|
||||
(data) => data.recipientssign
|
||||
);
|
||||
if (checkTourRecipients && checkTourRecipients.length > 0) {
|
||||
setCheckTourStatus(checkTourRecipients[0].recipientssign);
|
||||
}
|
||||
setSignerUserId(currUserId);
|
||||
const tourstatus = json[0].TourStatus && json[0].TourStatus;
|
||||
|
||||
if (tourstatus && tourstatus.length > 0) {
|
||||
setTourStatus(tourstatus);
|
||||
const checkTourRecipients = tourstatus.filter(
|
||||
(data) => data.recipientssign
|
||||
);
|
||||
if (checkTourRecipients && checkTourRecipients.length > 0) {
|
||||
setCheckTourStatus(checkTourRecipients[0].recipientssign);
|
||||
}
|
||||
} else {
|
||||
setNoData(true);
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
} else if (json === "Error: Something went wrong!") {
|
||||
const loadObj = {
|
||||
@@ -132,18 +139,16 @@ function EmbedPdfImage() {
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
} else {
|
||||
const json = await contactBookName(contactBookId, "_Users");
|
||||
|
||||
if (json !== "Error: Something went wrong!" && json && json.results[0]) {
|
||||
const json = await contractUsers(jsonSender.email);
|
||||
if (json && json.length > 0) {
|
||||
setContractName("_Users");
|
||||
if (json.results[0]) {
|
||||
userObjectId = json.results[0].UserId.objectId;
|
||||
if (json[0]) {
|
||||
userObjectId = json[0].UserId.objectId;
|
||||
setUserObjectID(userObjectId);
|
||||
currUserId = json.results[0].objectId;
|
||||
currUserId = json[0].objectId;
|
||||
|
||||
setSignerUserId(currUserId);
|
||||
const tourstatus =
|
||||
json.results[0].TourStatus && json.results[0].TourStatus;
|
||||
const tourstatus = json[0].TourStatus && json[0].TourStatus;
|
||||
|
||||
if (tourstatus && tourstatus.length > 0) {
|
||||
setTourStatus(tourstatus);
|
||||
@@ -167,171 +172,170 @@ function EmbedPdfImage() {
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setNoData(true);
|
||||
|
||||
await axios
|
||||
.get(
|
||||
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
|
||||
"_appName"
|
||||
)}_Document?where={"objectId":"${docId}"}&include=ExtUserPtr,Signers,AuditTrail
|
||||
,`,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
|
||||
}
|
||||
}
|
||||
)
|
||||
.then((Listdata) => {
|
||||
const json = Listdata.data;
|
||||
const res = json.results;
|
||||
if (res[0] && res.length > 0) {
|
||||
const declined = res[0].IsDeclined && res[0].IsDeclined;
|
||||
const isCompleted = res[0].IsCompleted && res[0].IsCompleted;
|
||||
const expireDate = res[0].ExpiryDate.iso;
|
||||
|
||||
const expireUpdateDate = new Date(expireDate).getTime();
|
||||
const currDate = new Date().getTime();
|
||||
if (isCompleted) {
|
||||
//checking document is completed (signed by all requested signers) than isCompleted true
|
||||
//then show alert with completed message
|
||||
const alreadySign = {
|
||||
status: true,
|
||||
mssg: "This document has been successfully signed!"
|
||||
};
|
||||
setIsAlreadySign(alreadySign);
|
||||
setPdfUrl(res[0].SignedUrl);
|
||||
setSignedPdfData(json.results);
|
||||
setCompletePdfData(res);
|
||||
} else if (declined) {
|
||||
const currentDecline = {
|
||||
currnt: "another",
|
||||
isDeclined: true
|
||||
};
|
||||
setIsDecline(currentDecline);
|
||||
|
||||
setSignedPdfData(json.results);
|
||||
} else if (currDate > expireUpdateDate) {
|
||||
setIsExpired(true);
|
||||
const checkDocIdExist =
|
||||
json.results[0].AuditTrail &&
|
||||
json.results[0].AuditTrail.length > 0 &&
|
||||
json.results[0].AuditTrail.filter(
|
||||
(data) => data.Activity === "Signed"
|
||||
);
|
||||
|
||||
//if signed by someone than go to in if condition
|
||||
// and second signer could not be add documentId
|
||||
//for that setIsDocId true
|
||||
if (checkDocIdExist && checkDocIdExist.length > 0) {
|
||||
setIsDocId(true);
|
||||
const currUser =
|
||||
json.results[0].Placeholders &&
|
||||
json.results[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(json.results);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
//for show current requested signer's placeholder
|
||||
else {
|
||||
const currUser =
|
||||
json.results[0].Placeholders &&
|
||||
json.results[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(json.results);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
} else {
|
||||
//checking document has signed by someone or not
|
||||
|
||||
const checkDocIdExist =
|
||||
json.results[0].AuditTrail &&
|
||||
json.results[0].AuditTrail.length > 0 &&
|
||||
json.results[0].AuditTrail.filter(
|
||||
(data) => data.Activity === "Signed"
|
||||
);
|
||||
|
||||
//if signed by someone than go to in if condition
|
||||
// and second signer could not be add documentId
|
||||
//for that setIsDocId true
|
||||
|
||||
if (checkDocIdExist && checkDocIdExist.length > 0) {
|
||||
setIsDocId(true);
|
||||
|
||||
//condition for checking document signed by current requested user or not
|
||||
const checkAlreadyBySigner = json.results[0].AuditTrail.filter(
|
||||
(data) =>
|
||||
data.UserPtr.objectId === currUserId &&
|
||||
data.Activity === "Signed"
|
||||
);
|
||||
|
||||
// if checkAlreadyBySigner has some data that current user already sign this document
|
||||
// then show alert with message
|
||||
if (checkAlreadyBySigner && checkAlreadyBySigner.length > 0) {
|
||||
const alreadySign = {
|
||||
status: true,
|
||||
mssg: "You have successfully signed the document!"
|
||||
};
|
||||
setIsAlreadySign(alreadySign);
|
||||
setPdfUrl(res[0].SignedUrl);
|
||||
setSignedPdfData(json.results);
|
||||
}
|
||||
//else show placeholder of current requested signer
|
||||
else {
|
||||
const currUser =
|
||||
json.results[0].Placeholders &&
|
||||
json.results[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(json.results);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
}
|
||||
//for show current requested signer's placeholder
|
||||
else {
|
||||
const currUser =
|
||||
json.results[0].Placeholders &&
|
||||
json.results[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(json.results);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
console.log("err", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//getting document details
|
||||
const documentData = await contractDocument(docId);
|
||||
if (documentData && documentData.length > 0) {
|
||||
const declined = documentData[0].IsDeclined && documentData[0].IsDeclined;
|
||||
const isCompleted =
|
||||
documentData[0].IsCompleted && documentData[0].IsCompleted;
|
||||
const expireDate = documentData[0].ExpiryDate.iso;
|
||||
|
||||
const expireUpdateDate = new Date(expireDate).getTime();
|
||||
const currDate = new Date().getTime();
|
||||
if (isCompleted) {
|
||||
//checking document is completed (signed by all requested signers) than isCompleted true
|
||||
//then show alert with completed message
|
||||
const alreadySign = {
|
||||
status: true,
|
||||
mssg: "This document has been successfully signed!"
|
||||
};
|
||||
setIsAlreadySign(alreadySign);
|
||||
setPdfUrl(documentData[0].SignedUrl);
|
||||
setSignedPdfData(documentData);
|
||||
setCompletePdfData(documentData);
|
||||
} else if (declined) {
|
||||
const currentDecline = {
|
||||
currnt: "another",
|
||||
isDeclined: true
|
||||
};
|
||||
setIsDecline(currentDecline);
|
||||
|
||||
setSignedPdfData(documentData);
|
||||
} else if (currDate > expireUpdateDate) {
|
||||
setIsExpired(true);
|
||||
const checkDocIdExist =
|
||||
documentData[0].AuditTrail &&
|
||||
documentData[0].AuditTrail.length > 0 &&
|
||||
documentData[0].AuditTrail.filter(
|
||||
(data) => data.Activity === "Signed"
|
||||
);
|
||||
|
||||
//if signed by someone than go to in if condition
|
||||
// and second signer could not be add documentId
|
||||
//for that setIsDocId true
|
||||
if (checkDocIdExist && checkDocIdExist.length > 0) {
|
||||
setIsDocId(true);
|
||||
const currUser =
|
||||
documentData.Placeholders &&
|
||||
documentData.Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(documentData);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
//for show current requested signer's placeholder
|
||||
else {
|
||||
const currUser =
|
||||
documentData[0].Placeholders &&
|
||||
documentData[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(documentData);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
} else {
|
||||
//checking document has signed by someone or not
|
||||
|
||||
const checkDocIdExist =
|
||||
documentData[0].AuditTrail &&
|
||||
documentData[0].AuditTrail.length > 0 &&
|
||||
documentData[0].AuditTrail.filter(
|
||||
(data) => data.Activity === "Signed"
|
||||
);
|
||||
|
||||
//if signed by someone than go to in if condition
|
||||
// and second signer could not be add documentId
|
||||
//for that setIsDocId true
|
||||
|
||||
if (checkDocIdExist && checkDocIdExist.length > 0) {
|
||||
setIsDocId(true);
|
||||
|
||||
//condition for checking document signed by current requested user or not
|
||||
const checkAlreadyBySigner = documentData[0].AuditTrail.filter(
|
||||
(data) =>
|
||||
data.UserPtr.objectId === currUserId && data.Activity === "Signed"
|
||||
);
|
||||
|
||||
// if checkAlreadyBySigner has some data that current user already sign this document
|
||||
// then show alert with message
|
||||
if (checkAlreadyBySigner && checkAlreadyBySigner.length > 0) {
|
||||
const alreadySign = {
|
||||
status: true,
|
||||
mssg: "You have successfully signed the document!"
|
||||
};
|
||||
setIsAlreadySign(alreadySign);
|
||||
setPdfUrl(documentData[0].SignedUrl);
|
||||
setSignedPdfData(documentData);
|
||||
}
|
||||
//else show placeholder of current requested signer
|
||||
else {
|
||||
const currUser =
|
||||
documentData[0].Placeholders &&
|
||||
documentData[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(documentData);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
}
|
||||
//for show current requested signer's placeholder
|
||||
else {
|
||||
const currUser =
|
||||
documentData[0].Placeholders &&
|
||||
documentData[0].Placeholders.filter(
|
||||
(data) => data.signerObjId === currUserId
|
||||
);
|
||||
|
||||
setSignedPdfData(documentData);
|
||||
|
||||
setXyPostion(currUser[0].placeHolder);
|
||||
|
||||
const key = currUser[0].placeHolder[0].pos[0].key;
|
||||
setSignKey(key);
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
documentData === "Error: Something went wrong!" ||
|
||||
(documentData.result && documentData.result.error)
|
||||
) {
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
} else {
|
||||
setNoData(true);
|
||||
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
await axios
|
||||
.get(
|
||||
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
|
||||
@@ -445,7 +449,7 @@ function EmbedPdfImage() {
|
||||
imgUrlList.map(async (data) => {
|
||||
//cheking signUrl is defau;t signature url of custom url
|
||||
let ImgUrl = data.SignUrl;
|
||||
const checkUrl = ImgUrl.includes("https:");
|
||||
const checkUrl = urlValidator(ImgUrl);
|
||||
|
||||
//if default signature url then convert it in base 64
|
||||
if (checkUrl) {
|
||||
@@ -503,7 +507,7 @@ function EmbedPdfImage() {
|
||||
const newUrl = await convertPNGtoJPEG(signUrl);
|
||||
signUrl = newUrl;
|
||||
}
|
||||
const checkUrl = url.SignUrl.includes("https:");
|
||||
const checkUrl = urlValidator(signUrl);
|
||||
if (checkUrl) {
|
||||
signUrl = signUrl + "?get";
|
||||
}
|
||||
@@ -984,7 +988,11 @@ function EmbedPdfImage() {
|
||||
}}
|
||||
>
|
||||
{/* this modal is used show this document is already sign */}
|
||||
<Modal show={isAlreadySign.status}>
|
||||
<Modal
|
||||
show={isAlreadySign.status}
|
||||
onShow={() => modalAlign()}
|
||||
backdropClassName="signature-backdrop"
|
||||
>
|
||||
<ModalHeader style={{ background: themeColor() }}>
|
||||
<span style={{ color: "white" }}> Sign Documents</span>
|
||||
</ModalHeader>
|
||||
|
||||
Reference in New Issue
Block a user