diff --git a/microfrontends/SignDocuments/src/Component/DraftDocument.js b/microfrontends/SignDocuments/src/Component/DraftDocument.js
index 79806a94e..95ab370b9 100644
--- a/microfrontends/SignDocuments/src/Component/DraftDocument.js
+++ b/microfrontends/SignDocuments/src/Component/DraftDocument.js
@@ -1,61 +1,47 @@
import React, { useEffect, useState } from "react";
-import axios from "axios";
import { useNavigate } from "react-router-dom";
import Loader from "./component/loader";
-import { getHostUrl } from "../utils/Utils";
+import { contractDocument, getHostUrl } from "../utils/Utils";
function DraftDocument() {
const navigate = useNavigate();
const [pdfDetails, setPdfDetails] = useState([]);
const [isLoading, setIsLoading] = useState({
isLoad: true,
- message: "This might take some time",
+ message: "This might take some time"
});
const rowLevel =
localStorage.getItem("rowlevel") &&
JSON.parse(localStorage.getItem("rowlevel"));
- const signObjId =
+ const docId =
rowLevel && rowLevel?.id
? rowLevel.id
: rowLevel?.objectId && rowLevel.objectId;
+
useEffect(() => {
- if (signObjId) {
+ if (docId) {
getDocumentDetails();
}
}, []);
//get document details
const getDocumentDetails = async () => {
- await axios
- .get(
- `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
- "_appName"
- )}_Document?where={"objectId":"${signObjId}"}&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;
-
- if (res[0] && res.length > 0) {
- setPdfDetails(res);
- const loadObj = {
- isLoad: false,
- };
- setIsLoading(loadObj);
- } else {
- alert("No data found!");
- }
- })
- .catch((err) => {
- console.log("axois err ", err);
- });
+ //getting document details
+ const documentData = await contractDocument(docId);
+ 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!");
+ }
};
//check document type and render on signyour self and placeholder route
@@ -63,24 +49,25 @@ function DraftDocument() {
const data = pdfDetails[0];
const checkSignerExist =
pdfDetails[0] && pdfDetails[0].Signers && pdfDetails[0].Signers;
- const isPlaceholder =
+ const isPlaceholder =
pdfDetails[0].Placeholders && pdfDetails[0].Placeholders;
const isDecline = data.IsDeclined && data.IsDeclined;
const signUrl = data.SignedUrl && data.SignedUrl;
- const expireDate = pdfDetails[0] && pdfDetails[0].ExpiryDate.iso && pdfDetails[0].ExpiryDate.iso;
+ const expireDate =
+ pdfDetails[0] &&
+ pdfDetails[0].ExpiryDate.iso &&
+ pdfDetails[0].ExpiryDate.iso;
const expireUpdateDate = new Date(expireDate).getTime();
const currDate = new Date().getTime();
const hostUrl = getHostUrl();
//checking document is completed and signer exist then navigate to pdfRequestFiles file
if (data.IsCompleted && checkSignerExist) {
- navigate(`${hostUrl}pdfRequestFiles`);
+ navigate(`${hostUrl}pdfRequestFiles`);
}
//checking document is completed and signer does not exist then navigate to recipientSignPdf file
else if (data.IsCompleted && !checkSignerExist) {
- navigate(
- `${hostUrl}signaturePdf`
- );
+ navigate(`${hostUrl}signaturePdf`);
}
//checking document is declined by someone then navigate to pdfRequestFiles file
else if (isDecline) {
diff --git a/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js b/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js
index cd004168a..db0c94425 100644
--- a/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js
+++ b/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js
@@ -6,6 +6,7 @@ import PdfFileComponent from "./FolderDrive/legaDriveComponent";
import Modal from "react-bootstrap/Modal";
import ModalHeader from "react-bootstrap/esm/ModalHeader";
import { themeColor, iconColor } from "../../utils/ThemeColor/backColor";
+import { getDrive } from "../../utils/Utils";
function PdfFile() {
const scrollRef = useRef(null);
@@ -15,29 +16,18 @@ 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);
const [isLoading, setIsLoading] = useState({
isLoad: true,
- message: "This might take some time",
+ message: "This might take some time"
});
const [docId, setDocId] = useState();
const [handleError, setHandleError] = useState();
const [folderName, setFolderName] = useState([]);
- const senderUser =
- localStorage.getItem(
- `Parse/${localStorage.getItem("parseAppId")}/currentUser`
- ) &&
- localStorage.getItem(
- `Parse/${localStorage.getItem("parseAppId")}/currentUser`
- );
- const jsonSender = JSON.parse(senderUser);
-
useEffect(() => {
if (docId) {
getPdfFolderDocumentList();
@@ -50,104 +40,59 @@ function PdfFile() {
const getPdfDocumentList = async () => {
const load = {
isLoad: true,
- message: "This might take some time",
+ message: "This might take some time"
};
setIsLoading(load);
- //?where={"Type":"Folder" }&include=ExtUserPtr,Signers
- //?where={"$or":[{"Type":{"$exists":true}},{"Folder":{"$exists":false}}]}&include=ExtUserPtr,Signers
- // "CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${jsonSender.objectId}"}
- // where={"Folder":{"$exists":false} }&include=ExtUserPtr,Signers`,
- await axios
- .get(
- `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
- "_appName"
- )}_Document?where={"Folder":{"$exists":false},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${
- jsonSender.objectId
- }"}}]}&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;
- // console.log("result", res);
- if (res[0] && res.length > 0) {
- setPdfData(res);
- }
+ const driveDetails = await getDrive();
- const data = [
- {
- name: "OpenSignDrive™",
- objectId: "",
- },
- ];
- setFolderName(data);
- const loadObj = {
- isLoad: false,
- };
- setIsLoading(loadObj);
- })
- .catch((err) => {
- const loadObj = {
- isLoad: false,
- };
- setHandleError("Error: Something went wrong!");
- setIsLoading(loadObj);
- });
+ if (driveDetails) {
+ if (driveDetails.length > 0) {
+ setPdfData(driveDetails);
+ }
+ const data = [
+ {
+ name: "OpenSignDrive™",
+ objectId: ""
+ }
+ ];
+ setFolderName(data);
+ const loadObj = {
+ isLoad: false
+ };
+ setIsLoading(loadObj);
+ } else if (driveDetails === "Error: Something went wrong!") {
+ const loadObj = {
+ isLoad: false
+ };
+ setHandleError("Error: Something went wrong!");
+ setIsLoading(loadObj);
+ }
};
//function for get parent folder document list
const getPdfFolderDocumentList = async () => {
const load = {
isLoad: true,
- message: "This might take some time",
+ message: "This might take some time"
};
setIsLoading(load);
- //{"$inQuery":{"where":{"objectId":"${docId}"},"className":"${appName}_Document"}}
- //"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${jsonSender.objectId}"}
- await axios
- .get(
- `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
- "_appName"
- )}_Document?where={"Folder":{"__type":"Pointer","className":"${localStorage.getItem(
- "_appName"
- )}_Document","objectId":"${docId}"},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${
- jsonSender.objectId
- }"}}]}&include=ExtUserPtr,Signers,Folder`,
- {
- 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) {
- setPdfData(res);
- } else {
- setPdfData([]);
- }
-
- const loadObj = {
- isLoad: false,
- };
- setIsLoading(loadObj);
- })
- .catch((err) => {
- const loadObj = {
- isLoad: false,
- };
- setHandleError("Error: Something went wrong!");
- setIsLoading(loadObj);
- });
+ const driveDetails = await getDrive(docId);
+ if (driveDetails) {
+ if (driveDetails.length > 0) {
+ setPdfData(driveDetails);
+ } else {
+ setPdfData([]);
+ }
+ const loadObj = {
+ isLoad: false
+ };
+ setIsLoading(loadObj);
+ } else if (driveDetails === "Error: Something went wrong!") {
+ const loadObj = {
+ isLoad: false
+ };
+ setHandleError("Error: Something went wrong!");
+ setIsLoading(loadObj);
+ }
};
//function for get all pdf document list
@@ -158,7 +103,7 @@ function PdfFile() {
const handleRoute = (data) => {
let loadObj = {
isLoad: true,
- message: "This might take some time",
+ message: "This might take some time"
};
if (data.name === "LegaDrive™") {
setIsLoading(loadObj);
@@ -167,7 +112,7 @@ function PdfFile() {
} else {
setTimeout(() => {
const loadObj = {
- isLoad: false,
+ isLoad: false
};
setIsLoading(loadObj);
}, 1000);
@@ -176,12 +121,11 @@ function PdfFile() {
setIsLoading(loadObj);
setTimeout(() => {
const loadObj = {
- isLoad: false,
+ isLoad: false
};
setIsLoading(loadObj);
}, 1000);
} else {
- // console.log("go here1",data.objectId)
const findIndex = folderName.findIndex(
(fold) => fold.objectId === data.objectId
);
@@ -216,13 +160,13 @@ function PdfFile() {
Folder: {
__type: "Pointer",
className: `${localStorage.getItem("_appName")}_Document`,
- objectId: isParentId,
- },
+ objectId: isParentId
+ }
};
} else {
data = {
Name: newFolderName,
- Type: "Folder",
+ Type: "Folder"
};
}
@@ -237,8 +181,8 @@ function PdfFile() {
headers: {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
- "X-Parse-Session-Token": localStorage.getItem("accesstoken"),
- },
+ "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ }
}
)
@@ -388,7 +332,7 @@ function PdfFile() {
display: "flex",
flexDirection: "column",
justifyContent: "center",
- alignItems: "center",
+ alignItems: "center"
}}
>
Name*
@@ -428,7 +372,7 @@ function PdfFile() {
display: "flex",
alignItems: "flex-end",
justifyContent: "flex-end",
- alignContent: "flex-end",
+ alignContent: "flex-end"
}}
>