From c185c42b80d1d756d9600b8b31d11f459afa7b99 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Sat, 30 Dec 2023 19:52:36 +0530 Subject: [PATCH] vertically center button in reports, add title for template route and placeholder route --- .../src/primitives/GetReportDisplay.js | 128 +++++++++++------- .../src/Component/TemplatePlaceholder.js | 3 +- .../src/Component/placeHolderSign.js | 5 +- 3 files changed, 85 insertions(+), 51 deletions(-) diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js index 8471d98de..fc8fa414d 100644 --- a/apps/OpenSign/src/primitives/GetReportDisplay.js +++ b/apps/OpenSign/src/primitives/GetReportDisplay.js @@ -21,8 +21,11 @@ const ReportTable = ({ const [actLoader, setActLoader] = useState({}); const [isAlert, setIsAlert] = useState(false); const [isErr, setIsErr] = useState(false); + const [isDocErr, setIsDocErr] = useState(false); const [isContactform, setIsContactform] = useState(false); const [isDeleteModal, setIsDeleteModal] = useState({}); + const startIndex = (currentPage - 1) * docPerPage; + // For loop is used to calculate page numbers visible below table // Initialize pageNumbers using useMemo to avoid unnecessary re-creation const pageNumbers = useMemo(() => { @@ -65,7 +68,7 @@ const ReportTable = ({ if (btnLabel === "Edit") { navigate(`/asmf/${url}/${item.objectId}`); } else { - setActLoader({ [item.objectId]: true }); + setActLoader({ [`${item.objectId}_${btnLabel}`]: true }); try { const params = { templateId: item.objectId @@ -104,46 +107,59 @@ const ReportTable = ({ signers.push(obj); } }); - } - const data = { - Name: Doc.Name, - URL: Doc.URL, - SignedUrl: Doc.SignedUrl, - Description: Doc.Description, - Note: Doc.Note, - Placeholders: placeholdersArr, - ExtUserPtr: { - __type: "Pointer", - className: "contracts_Users", - objectId: Doc.ExtUserPtr.objectId - }, - CreatedBy: { - __type: "Pointer", - className: "_User", - objectId: Doc.CreatedBy.objectId - }, - Signers: signers - }; + const data = { + Name: Doc.Name, + URL: Doc.URL, + SignedUrl: Doc.SignedUrl, + Description: Doc.Description, + Note: Doc.Note, + Placeholders: placeholdersArr, + ExtUserPtr: { + __type: "Pointer", + className: "contracts_Users", + objectId: Doc.ExtUserPtr.objectId + }, + CreatedBy: { + __type: "Pointer", + className: "_User", + objectId: Doc.CreatedBy.objectId + }, + Signers: signers + }; + try { + const res = await axios.post( + `${localStorage.getItem( + "baseUrl" + )}classes/${localStorage.getItem("_appName")}_Document`, + data, + { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": + localStorage.getItem("parseAppId"), + "X-Parse-Session-Token": + localStorage.getItem("accesstoken") + } + } + ); - const res = await axios.post( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document`, - data, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") + // console.log("Res ", res.data); + if (res.data && res.data.objectId) { + setActLoader({}); + setIsAlert(true); + navigate(`/asmf/${url}/${res.data.objectId}`, { + state: { title: "Use Template" } + }); } + } catch (err) { + console.log("Err", err); + setIsAlert(true); + setIsErr(true); + setActLoader({}); } - ); - - // console.log("Res ", res.data); - if (res.data && res.data.objectId) { + } else { + setIsDocErr(true); setActLoader({}); - setIsAlert(true); - navigate(`/asmf/${url}/${res.data.objectId}`); } } else { setIsAlert(true); @@ -190,7 +206,7 @@ const ReportTable = ({ }; const handleDelete = async (item) => { - setIsDeleteModal({}) + setIsDeleteModal({}); setActLoader({ [item.objectId]: true }); try { const url = @@ -264,12 +280,12 @@ const ReportTable = ({ ReportName === "Contactbook" ? ( {heading.includes("Sr.No") && ( - {index + 1} + {startIndex + index + 1} )} {item?.Name} {item?.Email || "-"} {item?.Phone || "-"} - + {actions?.length > 0 && actions.map((act, index) => (