mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 07:02:32 +02:00
add createDocument from template functionality
This commit is contained in:
@@ -22,7 +22,8 @@ import {
|
||||
contractUsers,
|
||||
getHostUrl,
|
||||
randomId,
|
||||
addZIndex
|
||||
addZIndex,
|
||||
createDocument
|
||||
} from "../utils/Utils";
|
||||
import RenderPdf from "./component/renderPdf";
|
||||
import ModalComponent from "./component/modalComponent";
|
||||
@@ -171,24 +172,22 @@ const TemplatePlaceholder = () => {
|
||||
}
|
||||
}, [divRef.current]);
|
||||
const fetchTemplate = async () => {
|
||||
const templateDeatils = await axios.get(
|
||||
`${localStorage.getItem("baseUrl")}classes/contracts_Template/` +
|
||||
templateId,
|
||||
const params = { templateId: templateId };
|
||||
const templateDeatils = await axios.post(
|
||||
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
|
||||
params,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
|
||||
},
|
||||
params: {
|
||||
include: "ExtUserPtr,Signers,CreatedBy"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// console.log("templateDeatils.data ", templateDeatils.data);
|
||||
const documentData =
|
||||
templateDeatils.data && templateDeatils.data
|
||||
? [templateDeatils.data]
|
||||
templateDeatils.data && templateDeatils.data.result
|
||||
? [templateDeatils.data.result]
|
||||
: [];
|
||||
// console.log("documentData ", documentData)
|
||||
if (documentData && documentData.length > 0) {
|
||||
@@ -802,10 +801,16 @@ const TemplatePlaceholder = () => {
|
||||
console.log("axois err ", err);
|
||||
});
|
||||
};
|
||||
const handleCreateDocModal = () => {
|
||||
const handleCreateDocModal = async () => {
|
||||
const hostUrl = getHostUrl();
|
||||
// handle create document
|
||||
navigate(`${hostUrl}placeHolderSign/${templateId}`);
|
||||
console.log("template ", pdfDetails);
|
||||
const res = await createDocument(pdfDetails);
|
||||
if (res.status === "success") {
|
||||
navigate(`${hostUrl}placeHolderSign/${res.id}`);
|
||||
} else {
|
||||
setHandleError("Error: Something went wrong!");
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddSigner = () => {
|
||||
|
||||
@@ -186,9 +186,9 @@ function PlaceHolderSign() {
|
||||
if (documentData && documentData.length > 0) {
|
||||
const alreadyPlaceholder =
|
||||
documentData[0].Placeholders && documentData[0].Placeholders;
|
||||
if (alreadyPlaceholder && alreadyPlaceholder.length > 0) {
|
||||
setIsAlreadyPlace(true);
|
||||
}
|
||||
// if (alreadyPlaceholder && alreadyPlaceholder.length > 0) {
|
||||
// setIsAlreadyPlace(true);
|
||||
// }
|
||||
setPdfDetails(documentData);
|
||||
const currEmail = documentData[0].ExtUserPtr.Email;
|
||||
const filterCurrEmail = documentData[0].Signers.filter(
|
||||
@@ -201,6 +201,12 @@ function PlaceHolderSign() {
|
||||
setSignerObjId(documentData[0].Signers[0].objectId);
|
||||
setContractName(documentData[0].Signers[0].className);
|
||||
setIsSelectId(0);
|
||||
if (documentData[0].Placeholders && documentData[0].Placeholders.length > 0){
|
||||
setSignerPos(documentData[0].Placeholders)
|
||||
}
|
||||
if (documentData[0].Signers && documentData[0].Signers.length > 0){
|
||||
setSignersData(documentData[0].Signers)
|
||||
}
|
||||
} else if (
|
||||
documentData === "Error: Something went wrong!" ||
|
||||
(documentData.result && documentData.result.error)
|
||||
@@ -947,7 +953,7 @@ function PlaceHolderSign() {
|
||||
)}
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
<ModalComponent isShow={isAlreadyPlace} type={"alreadyPlace"} />
|
||||
{/* <ModalComponent isShow={isAlreadyPlace} type={"alreadyPlace"} /> */}
|
||||
<ModalComponent
|
||||
isShow={isShowEmail}
|
||||
type={"signersAlert"}
|
||||
|
||||
Reference in New Issue
Block a user