remove contracts_Document & contracts_Users query from frontend and call cloud function

This commit is contained in:
RaktimaNXG
2023-11-20 16:46:27 +05:30
parent 06cdb660b3
commit 910bd801ac
7 changed files with 557 additions and 637 deletions
@@ -15,7 +15,7 @@ import EmailComponent from "./component/emailComponent";
import FieldsComponent from "./component/fieldsComponent";
import Modal from "react-bootstrap/Modal";
import ModalHeader from "react-bootstrap/esm/ModalHeader";
import { getBase64FromIMG } from "../utils/Utils";
import { contractDocument, getBase64FromIMG } from "../utils/Utils";
import { useParams } from "react-router-dom";
import Tour from "reactour";
import { onSaveImage, onSaveSign } from "../utils/Utils";
@@ -173,55 +173,41 @@ function SignYourSelf() {
//function for get document details for perticular signer with signer'object id
const getDocumentDetails = async () => {
await axios
.get(
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
"_appName"
)}_Document?where={"objectId":"${documentId}"}&include=ExtUserPtr,Signers`,
{
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;
//getting document details
const documentData = await contractDocument(documentId);
if (res[0] && res.length > 0) {
setPdfDetails(res);
const isCompleted = res[0].IsCompleted && res[0].IsCompleted;
if (isCompleted) {
const docStatus = {
isCompleted: isCompleted
};
setDocumentStatus(docStatus);
const alreadySign = {
status: true,
mssg: "You have successfully signed the document!"
};
setShowAlreadySignDoc(alreadySign);
setPdfUrl(res[0].SignedUrl);
}
} else {
setNoData(true);
const loadObj = {
isLoad: false
};
setIsLoading(loadObj);
}
})
.catch((err) => {
const loadObj = {
isLoad: false
if (documentData && documentData !== "no data found!" && documentData[0]) {
setPdfDetails(documentData);
const isCompleted =
documentData[0].IsCompleted && documentData[0].IsCompleted;
if (isCompleted) {
const docStatus = {
isCompleted: isCompleted
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
});
setDocumentStatus(docStatus);
const alreadySign = {
status: true,
mssg: "You have successfully signed the document!"
};
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!") {
const loadObj = {
isLoad: false
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
}
await axios
.get(
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
@@ -252,7 +238,8 @@ function SignYourSelf() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
});
const contractUsersRes = await contractUsers(jsonSender.objectId);
const contractUsersRes = await contractUsers(jsonSender.email);
if (
contractUsersRes !== "Error: Something went wrong!" &&
@@ -287,12 +274,10 @@ function SignYourSelf() {
const contractContactBook = await contactBook(jsonSender.objectId);
if (contractContactBook && contractContactBook[0]) {
setContractName("_Contactbook");
setSignerUserId(contractContactBook[0].objectId);
const tourstatuss =
contractContactBook[0].TourStatus &&
contractContactBook[0].TourStatus;
if (tourstatuss && tourstatuss.length > 0) {
setTourStatus(tourstatuss);
const checkTourRecipients = tourstatuss.filter(