mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 15:12:34 +02:00
handle condition of no data for contracts_Document and contracts_ContactBook classes
This commit is contained in:
@@ -28,18 +28,19 @@ function DraftDocument() {
|
||||
const getDocumentDetails = async () => {
|
||||
//getting document details
|
||||
const documentData = await contractDocument(docId);
|
||||
if (documentData && documentData !== "no data found!" && documentData[0]) {
|
||||
if (documentData[0] && documentData.length > 0) {
|
||||
setPdfDetails(documentData);
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
} else if (documentData === "no data found!") {
|
||||
alert("No data found!");
|
||||
} else if (documentData === "Error: Something went wrong!") {
|
||||
if (documentData && documentData.length > 0) {
|
||||
setPdfDetails(documentData);
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
} else if (
|
||||
documentData === "Error: Something went wrong!" ||
|
||||
(documentData.result && documentData.result.error)
|
||||
) {
|
||||
alert("Error: Something went wrong!");
|
||||
} else {
|
||||
alert("No data found!");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ function PdfFile() {
|
||||
const [pdfData, setPdfData] = useState([]);
|
||||
const [isFolder, setIsFolder] = useState(false);
|
||||
const [newFolderName, setNewFolderName] = useState();
|
||||
// const [parentFolderName, setParentFolderName] = useState();
|
||||
// const [parentFolder, setParentFolder] = useState([]);
|
||||
const [error, setError] = useState();
|
||||
const [folderLoader, setIsFolderLoader] = useState(false);
|
||||
const [isShowSort, setIsShowSort] = useState(false);
|
||||
@@ -48,7 +46,7 @@ function PdfFile() {
|
||||
const driveDetails = await getDrive();
|
||||
|
||||
if (driveDetails) {
|
||||
if (driveDetails && driveDetails.length > 0) {
|
||||
if (driveDetails.length > 0) {
|
||||
setPdfData(driveDetails);
|
||||
}
|
||||
const data = [
|
||||
@@ -79,7 +77,7 @@ function PdfFile() {
|
||||
setIsLoading(load);
|
||||
const driveDetails = await getDrive(docId);
|
||||
if (driveDetails) {
|
||||
if (driveDetails && driveDetails.length > 0) {
|
||||
if (driveDetails.length > 0) {
|
||||
setPdfData(driveDetails);
|
||||
} else {
|
||||
setPdfData([]);
|
||||
|
||||
@@ -112,7 +112,7 @@ function PdfRequestFiles() {
|
||||
const getDocumentDetails = async () => {
|
||||
//getting document details
|
||||
const documentData = await contractDocument(documentId);
|
||||
if (documentData && documentData !== "no data found!" && documentData[0]) {
|
||||
if (documentData && documentData.length > 0) {
|
||||
const isCompleted =
|
||||
documentData[0].IsCompleted && documentData[0].IsCompleted;
|
||||
const expireDate = documentData[0].ExpiryDate.iso;
|
||||
@@ -222,19 +222,22 @@ function PdfRequestFiles() {
|
||||
} else {
|
||||
alert("No data found!");
|
||||
}
|
||||
} else if (documentData === "no data found!") {
|
||||
} 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);
|
||||
setIsUiLoading(false);
|
||||
} else if (documentData === "Error: Something went wrong!") {
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
await axios
|
||||
.get(
|
||||
|
||||
@@ -176,7 +176,7 @@ function SignYourSelf() {
|
||||
//getting document details
|
||||
const documentData = await contractDocument(documentId);
|
||||
|
||||
if (documentData && documentData !== "no data found!" && documentData[0]) {
|
||||
if (documentData && documentData.length > 0) {
|
||||
setPdfDetails(documentData);
|
||||
const isCompleted =
|
||||
documentData[0].IsCompleted && documentData[0].IsCompleted;
|
||||
@@ -193,21 +193,22 @@ function SignYourSelf() {
|
||||
setShowAlreadySignDoc(alreadySign);
|
||||
setPdfUrl(documentData[0].SignedUrl);
|
||||
}
|
||||
} else if (documentData === "no data found!") {
|
||||
setNoData(true);
|
||||
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
} else if (documentData === "Error: Something went wrong!") {
|
||||
} 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(
|
||||
@@ -241,11 +242,7 @@ function SignYourSelf() {
|
||||
|
||||
const contractUsersRes = await contractUsers(jsonSender.email);
|
||||
|
||||
if (
|
||||
contractUsersRes !== "Error: Something went wrong!" &&
|
||||
contractUsersRes &&
|
||||
contractUsersRes[0]
|
||||
) {
|
||||
if (contractUsersRes[0] && contractUsersRes.length > 0) {
|
||||
setContractName("_Users");
|
||||
setSignerUserId(contractUsersRes[0].objectId);
|
||||
const tourstatuss =
|
||||
@@ -272,7 +269,7 @@ function SignYourSelf() {
|
||||
setIsLoading(loadObj);
|
||||
} else if (contractUsersRes.length === 0) {
|
||||
const contractContactBook = await contactBook(jsonSender.objectId);
|
||||
if (contractContactBook && contractContactBook[0]) {
|
||||
if (contractContactBook && contractContactBook.length > 0) {
|
||||
setContractName("_Contactbook");
|
||||
setSignerUserId(contractContactBook[0].objectId);
|
||||
const tourstatuss =
|
||||
@@ -287,6 +284,8 @@ function SignYourSelf() {
|
||||
setCheckTourStatus(checkTourRecipients[0].signyourself);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setNoData(true);
|
||||
}
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
|
||||
@@ -176,7 +176,7 @@ function PlaceHolderSign() {
|
||||
const getDocumentDetails = async () => {
|
||||
//getting document details
|
||||
const documentData = await contractDocument(documentId);
|
||||
if (documentData && documentData !== "no data found!" && documentData[0]) {
|
||||
if (documentData && documentData.length > 0) {
|
||||
setPdfDetails(documentData);
|
||||
|
||||
const currEmail = documentData[0].ExtUserPtr.Email;
|
||||
@@ -190,19 +190,22 @@ function PlaceHolderSign() {
|
||||
setSignerObjId(documentData[0].Signers[0].objectId);
|
||||
setContractName(documentData[0].Signers[0].className);
|
||||
setIsSelectId(0);
|
||||
} else if (documentData === "no data found!") {
|
||||
} 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);
|
||||
} else if (documentData === "Error: Something went wrong!") {
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
const res = await contractUsers(jsonSender.email);
|
||||
if (res[0] && res.length) {
|
||||
|
||||
@@ -109,31 +109,24 @@ function EmbedPdfImage() {
|
||||
let currUserId, userObjectId;
|
||||
//getting contracts_contactBook details
|
||||
const json = await contactBook(contactBookId);
|
||||
if (json !== "Error: Something went wrong!" && json[0]) {
|
||||
if (json && json.length > 0) {
|
||||
setContractName("_Contactbook");
|
||||
if (json[0]) {
|
||||
userObjectId = json[0].UserId.objectId;
|
||||
setUserObjectID(userObjectId);
|
||||
currUserId = json[0].objectId;
|
||||
|
||||
setSignerUserId(currUserId);
|
||||
const tourstatus = json[0].TourStatus && json[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 = {
|
||||
@@ -143,7 +136,7 @@ function EmbedPdfImage() {
|
||||
setIsLoading(loadObj);
|
||||
} else {
|
||||
const json = await contractUsers(jsonSender.email);
|
||||
if (json !== "Error: Something went wrong!" && json && json[0]) {
|
||||
if (json && json.length > 0) {
|
||||
setContractName("_Users");
|
||||
if (json[0]) {
|
||||
userObjectId = json[0].UserId.objectId;
|
||||
@@ -175,12 +168,19 @@ function EmbedPdfImage() {
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
} else {
|
||||
setNoData(true);
|
||||
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
}
|
||||
|
||||
//getting document details
|
||||
const documentData = await contractDocument(docId);
|
||||
if (documentData && documentData !== "no data found!" && documentData[0]) {
|
||||
if (documentData && documentData.length > 0) {
|
||||
const declined = documentData[0].IsDeclined && documentData[0].IsDeclined;
|
||||
const isCompleted =
|
||||
documentData[0].IsCompleted && documentData[0].IsCompleted;
|
||||
@@ -315,19 +315,22 @@ function EmbedPdfImage() {
|
||||
setSignKey(key);
|
||||
}
|
||||
}
|
||||
} else if (documentData === "no data found!") {
|
||||
} 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);
|
||||
} else if (documentData === "Error: Something went wrong!") {
|
||||
const loadObj = {
|
||||
isLoad: false
|
||||
};
|
||||
setHandleError("Error: Something went wrong!");
|
||||
setIsLoading(loadObj);
|
||||
}
|
||||
await axios
|
||||
.get(
|
||||
|
||||
@@ -152,7 +152,6 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) {
|
||||
return obj;
|
||||
});
|
||||
return newUpdateUrl;
|
||||
// setXyPostion(newUpdateUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,11 +197,13 @@ export const contractDocument = async (documentId) => {
|
||||
.then((Listdata) => {
|
||||
const json = Listdata.data;
|
||||
let data = [];
|
||||
if (json && json.result) {
|
||||
if (json && json.result.error) {
|
||||
return json;
|
||||
} else if (json && json.result) {
|
||||
data.push(json.result);
|
||||
return data;
|
||||
} else {
|
||||
return "no data found!";
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -228,12 +229,13 @@ export const getDrive = async (documentId) => {
|
||||
.then((Listdata) => {
|
||||
const json = Listdata.data;
|
||||
|
||||
if (json && json.result) {
|
||||
if (json && json.result.error) {
|
||||
return json;
|
||||
} else if (json && json.result) {
|
||||
const data = json.result;
|
||||
|
||||
return data;
|
||||
} else {
|
||||
return "no data found!";
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -258,11 +260,10 @@ export const contractUsers = async (email) => {
|
||||
.then((Listdata) => {
|
||||
const json = Listdata.data;
|
||||
let data = [];
|
||||
|
||||
if (json && json.result) {
|
||||
data.push(json.result);
|
||||
return data;
|
||||
} else {
|
||||
return "no data found!";
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user