diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js index 6e92edce5..486c28c5a 100644 --- a/apps/OpenSign/src/json/ReportJson.js +++ b/apps/OpenSign/src/json/ReportJson.js @@ -12,11 +12,22 @@ export default function reportJson(id) { heading: head, actions: [ { - btnLabel: "sign", + btnId: "1231", + btnLabel: "Edit", btnColor: "#4bd396", textColor: "white", - btnIcon: "fa fa-plus", - redirectUrl: "draftDocument" + btnIcon: "fa-solid fa-pen", + redirectUrl: "draftDocument", + action: "redirect" + }, + { + btnId: "2142", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], helpMsg: @@ -29,11 +40,13 @@ export default function reportJson(id) { heading: head, actions: [ { - btnLabel: "sign", + btnId: "4536", + btnLabel: "Sign", btnColor: "#3ac9d6", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "pdfRequestFiles" + redirectUrl: "pdfRequestFiles", + action: "redirect" } ], helpMsg: @@ -46,11 +59,31 @@ export default function reportJson(id) { heading: head, actions: [ { + btnId: "8901", + btnLabel: "Share", + btnColor: "#3ac9d6", + textColor: "white", + btnIcon: "fa-solid fa-share", + redirectUrl: "", + action: "share" + }, + { + btnId: "1588", btnLabel: "View", btnColor: "#3ac9d6", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "pdfRequestFiles" + redirectUrl: "pdfRequestFiles", + action: "redirect" + }, + { + btnId: "1488", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], helpMsg: @@ -63,11 +96,22 @@ export default function reportJson(id) { heading: head, actions: [ { - btnLabel: "View", + btnId: "1378", + btnLabel: "Edit", btnColor: "#4bd396", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "draftDocument" + redirectUrl: "draftDocument", + action: "redirect" + }, + { + btnId: "1278", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], helpMsg: @@ -80,11 +124,22 @@ export default function reportJson(id) { heading: head, actions: [ { + btnId: "1458", btnLabel: "View", btnColor: "#4bd396", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "draftDocument" + redirectUrl: "draftDocument", + action: "redirect" + }, + { + btnId: "1358", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], helpMsg: @@ -97,11 +152,22 @@ export default function reportJson(id) { heading: head, actions: [ { + btnId: "1898", btnLabel: "View", btnColor: "#4bd396", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "draftDocument" + redirectUrl: "draftDocument", + action: "redirect" + }, + { + btnId: "1998", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], helpMsg: @@ -114,11 +180,22 @@ export default function reportJson(id) { heading: dashboardReportHead, actions: [ { + btnId: "1999", btnLabel: "View", btnColor: "#4bd396", textColor: "white", btnIcon: "fa fa-eye", - redirectUrl: "pdfRequestFiles" + redirectUrl: "pdfRequestFiles", + action: "redirect" + }, + { + btnId: "2000", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ] }; @@ -129,11 +206,13 @@ export default function reportJson(id) { heading: dashboardReportHead, actions: [ { + btnId: "2001", btnLabel: "Sign", btnColor: "#4bd396", textColor: "white", - btnIcon: "fa fa-eye", - redirectUrl: "pdfRequestFiles" + btnIcon: "fa-solid fa-signature", + redirectUrl: "pdfRequestFiles", + action: "redirect" } ] }; @@ -144,11 +223,22 @@ export default function reportJson(id) { heading: ["Title", "Note", "Folder", "File", "Owner", "Signers"], actions: [ { - btnLabel: "sign", + btnId: "2003", + btnLabel: "Edit", btnColor: "#4bd396", textColor: "white", - btnIcon: "fa fa-plus", - redirectUrl: "draftDocument" + btnIcon: "fa-solid fa-pen", + redirectUrl: "draftDocument", + action: "redirect" + }, + { + btnId: "2004", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ] }; @@ -159,10 +249,12 @@ export default function reportJson(id) { heading: contactbook, actions: [ { - btnLabel: "", + btnId: "2204", + btnLabel: "Delete", btnColor: "#f55a42", textColor: "white", - btnIcon: "fa-solid fa-trash" + btnIcon: "fa-solid fa-trash", + action: "delete" } ], form: "ContactBook", @@ -176,27 +268,33 @@ export default function reportJson(id) { heading: head, actions: [ { - btnLabel: "Use", + btnId: "2234", + btnLabel: "Create document", btnColor: "#4bd396", textColor: "white", btnIcon: "fa fa-plus", redirectUrl: "placeHolderSign", - selector: "reactourSecond", - message: - "Click the ‘Use’ button to create a new document from an existing template." + action: "redirect" }, { btnLabel: "Edit", + btnId: "2434", btnColor: "#00c9d5", textColor: "white", - btnIcon: "fa fa-plus", + btnIcon: "fa-solid fa-pen", redirectUrl: "template", - selector: "reactourThird", - message: - "Use the ‘Edit’ button to add signer roles, modify fields, and update your template. Changes will apply to all future documents created from this template but won’t affect existing documents." + action: "redirect" + }, + { + btnId: "1834", + btnLabel: "Delete", + btnColor: "#ff4848", + textColor: "white", + btnIcon: "fa fa-trash", + redirectUrl: "", + action: "delete" } ], - helpMsg: "This is a list of templates that are available to you for creating documents. You can click the 'use' button to create a new document using a template, modify the document & add signers in the next step." }; diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js index 914da3515..0445bf2db 100644 --- a/apps/OpenSign/src/primitives/GetReportDisplay.js +++ b/apps/OpenSign/src/primitives/GetReportDisplay.js @@ -3,12 +3,12 @@ import pad from "../assets/images/pad.svg"; import { useNavigate } from "react-router-dom"; import axios from "axios"; import ModalUi from "./ModalUi"; -import Tour from "reactour"; import AddSigner from "../components/AddSigner"; import { modalSubmitBtnColor, modalCancelBtnColor } from "../constant/const"; import Alert from "./Alert"; import Tooltip from "./Tooltip"; -import Parse from "parse"; +import { RWebShare } from "react-web-share"; + const ReportTable = ({ ReportName, List, @@ -19,9 +19,7 @@ const ReportTable = ({ isMoreDocs, docPerPage, form, - report_help, - tourData, - isDontShow + report_help }) => { const navigate = useNavigate(); const [currentPage, setCurrentPage] = useState(1); @@ -31,8 +29,9 @@ const ReportTable = ({ const [isDocErr, setIsDocErr] = useState(false); const [isContactform, setIsContactform] = useState(false); const [isDeleteModal, setIsDeleteModal] = useState({}); - const [isTour, setIsTour] = useState(false); - const [tourStatusArr, setTourStatusArr] = useState([]); + const [isShare, setIsShare] = useState({}); + const [shareUrls, setShareUrls] = useState([]); + const [copied, setCopied] = useState(false); const startIndex = (currentPage - 1) * docPerPage; // For loop is used to calculate page numbers visible below table @@ -46,7 +45,6 @@ const ReportTable = ({ }, [List, docPerPage]); // below useEffect reset currenpage to 1 if user change route useEffect(() => { - checkTourStatus(); return () => setCurrentPage(1); }, []); @@ -72,13 +70,13 @@ const ReportTable = ({ } }, [isMoreDocs, pageNumbers, currentPage, setIsNextRecord]); - // `handlemicroapp` is used to open microapp - const handlemicroapp = async (item, url, btnLabel) => { + // `handleURL` is used to open microapp + const handleURL = async (item, act) => { if (ReportName === "Templates") { - if (btnLabel === "Edit") { - navigate(`/${url}/${item.objectId}`); + if (act.btnLabel === "Edit") { + navigate(`/${act.redirectUrl}/${item.objectId}`); } else { - setActLoader({ [`${item.objectId}_${btnLabel}`]: true }); + setActLoader({ [`${item.objectId}_${act.btnId}`]: true }); try { const params = { templateId: item.objectId @@ -153,11 +151,13 @@ const ReportTable = ({ } } ); + + // console.log("Res ", res.data); if (res.data && res.data.objectId) { setActLoader({}); setIsAlert(true); setTimeout(() => setIsAlert(false), 1500); - navigate(`/${url}/${res.data.objectId}`, { + navigate(`/${act.redirectUrl}/${res.data.objectId}`, { state: { title: "Use Template" } }); } @@ -188,18 +188,20 @@ const ReportTable = ({ } } else { localStorage.removeItem("rowlevel"); - navigate(`/${url}`); + navigate(`/${act.redirectUrl}`); localStorage.setItem("rowlevel", JSON.stringify(item)); } - - // localStorage.setItem("rowlevelMicro"); }; - const handlebtn = async (item) => { - if (ReportName === "Contactbook") { + + const handleActionBtn = (act, item) => { + if (act.action === "redirect") { + handleURL(item, act); + } else if (act.action === "delete") { setIsDeleteModal({ [item.objectId]: true }); + } else if (act.action === "share") { + handleShare(item); } }; - // Get current list const indexOfLastDoc = currentPage * docPerPage; const indexOfFirstDoc = indexOfLastDoc - docPerPage; @@ -220,13 +222,21 @@ const ReportTable = ({ const handleDelete = async (item) => { setIsDeleteModal({}); - setActLoader({ [item.objectId]: true }); + setActLoader({ [`${item.objectId}`]: true }); + const clsObj = { + Contactbook: "contracts_Contactbook", + Templates: "contracts_Template" + }; try { const serverUrl = process.env.REACT_APP_SERVERURL ? process.env.REACT_APP_SERVERURL : window.location.origin + "/api/app"; - const url = serverUrl + "/classes/contracts_Contactbook/"; - const body = { IsDeleted: true }; + const cls = clsObj[ReportName] || "contracts_Document"; + const url = serverUrl + `/classes/${cls}/`; + const body = + ReportName === "Contactbook" + ? { IsDeleted: true } + : { IsArchive: true }; const res = await axios.put(url + item.objectId, body, { headers: { "Content-Type": "application/json", @@ -252,364 +262,354 @@ const ReportTable = ({ }; const handleCloseDeleteModal = () => setIsDeleteModal({}); - async function checkTourStatus() { - const currentUser = Parse.User.current(); - const cloudRes = await Parse.Cloud.run("getUserDetails", { - email: currentUser.get("email") - }); - const res = { data: cloudRes.toJSON() }; - if (res.data && res.data.TourStatus && res.data.TourStatus.length > 0) { - const tourStatus = res.data.TourStatus; - // console.log("res ", res.data.TourStatus); - setTourStatusArr(tourStatus); - const filteredtourStatus = tourStatus.filter( - (obj) => obj["templateReportTour"] - ); - if (filteredtourStatus.length > 0) { - const templateReportTour = filteredtourStatus[0]["templateReportTour"]; + const handleShare = (item) => { + setActLoader({ [item.objectId]: true }); + const host = window.location.origin; + const serverUrl = process.env.REACT_APP_SERVERURL + ? process.env.REACT_APP_SERVERURL + : window.location.origin + "/api/app"; + const baseURL = serverUrl.replace(/\//g, "%2F"); + const urls = item.Signers.map((x) => ({ + email: x.Email, + url: `${host}/login/${item.objectId}/${x.Email}/${x.objectId}/${baseURL}%2F&opensign&contracts` + })); + setShareUrls(urls); + setIsShare({ [item.objectId]: true }); + }; - if (templateReportTour) { - setIsTour(false); - } else { - setIsTour(true); - } - } else { - setIsTour(true); - } - } else { - setIsTour(true); - } - } - - const closeTour = async () => { - // console.log("closeTour"); - setIsTour(false); - if (isDontShow) { - const serverUrl = localStorage.getItem("baseUrl"); - const appId = localStorage.getItem("parseAppId"); - const extUserClass = localStorage.getItem("extended_class"); - const json = JSON.parse(localStorage.getItem("Extand_Class")); - const extUserId = json && json.length > 0 && json[0].objectId; - // console.log("extUserId ", extUserId) - - let updatedTourStatus = []; - if (tourStatusArr.length > 0) { - updatedTourStatus = [...tourStatusArr]; - const templateTourIndex = tourStatusArr.findIndex( - (obj) => - obj["templateReportTour"] === false || - obj["templateReportTour"] === true - ); - if (templateTourIndex !== -1) { - updatedTourStatus[templateTourIndex] = { templateReportTour: true }; - } else { - updatedTourStatus.push({ templateReportTour: true }); - } - } else { - updatedTourStatus = [{ templateReportTour: true }]; - } - - await axios.put( - serverUrl + "classes/" + extUserClass + "/" + extUserId, - { - TourStatus: updatedTourStatus - }, - { - headers: { - "X-Parse-Application-Id": appId - } - } - ); - } + const copytoclipboard = (share) => { + navigator.clipboard.writeText(share.url); + setCopied({ ...copied, [share.email]: true }); }; return ( -
- {isAlert && ( - - {isErr - ? "Something went wrong, Please try again later!" - : "Record deleted successfully!"} - +
+ {Object.keys(actLoader)?.length > 0 && ( +
+
+
)} - {tourData && ReportName === "Templates" && ( - - )} - -
-
- {ReportName}{" "} - {report_help && ( - - - +
+ {isAlert && ( + + {isErr + ? "Something went wrong, Please try again later!" + : "Record deleted successfully!"} + + )} +
+
+ {ReportName}{" "} + {report_help && ( + + + + )} +
+ {ReportName === "Templates" && ( + navigate("/form/template")} + className="fa-solid fa-square-plus text-sky-400 text-[25px]" + > + )} + {form && ( +
handleContactFormModal()} + > + +
)}
- {ReportName === "Templates" && ( - navigate("/form/template")} - className="fa-solid fa-square-plus text-sky-400 text-[25px]" - > - )} - {form && ( -
handleContactFormModal()} - > - -
- )} -
- - - - - {heading?.map((item, index) => ( - - - - ))} - {actions?.length > 0 && ( - - )} - - - - {List?.length > 0 ? ( - <> - {currentLists.map((item, index) => - ReportName === "Contactbook" ? ( - - {heading.includes("Sr.No") && ( - - )} - - - - -
{item}Action
{startIndex + index + 1}{item?.Name} {item?.Email || "-"}{item?.Phone || "-"} - {actions?.length > 0 && - actions.map((act, index) => ( - - ))} - {isDeleteModal[item.objectId] && ( - -
-
- Are you sure you want to delete this contact? -
-
-
- - -
-
-
+ + + + {heading?.map((item, index) => ( + + + + ))} + {actions?.length > 0 && ( + + )} + + + + {List?.length > 0 && ( + <> + {currentLists.map((item, index) => + ReportName === "Contactbook" ? ( + + {heading.includes("Sr.No") && ( + )} - - - ) : ( - - {heading.includes("Sr.No") && ( - - )} - - {heading.includes("Note") && ( - - )} - {heading.includes("Folder") && ( - + + + + + ) : ( + + {heading.includes("Sr.No") && ( + + )} + + {heading.includes("Note") && ( + + )} + {heading.includes("Folder") && ( + + )} + - )} - - - - + + - - ) +
+ {shareUrls.map((share, i) => ( +
+ + {share.email} + +
+ + + + +
+
+ ))} +
+ + )} + + + ) + )} + + )} + +
{item}Action
{startIndex + index + 1}
{startIndex + index + 1} - {item?.Name}{" "} - {item?.Note || "-"} - {item?.Folder?.Name || "OpenSign™ Drive"} + {item?.Name} {item?.Email || "-"}{item?.Phone || "-"} + {actions?.length > 0 && + actions.map((act, index) => ( + + ))} + {isDeleteModal[item.objectId] && ( + +
+
+ Are you sure you want to delete this contact? +
+
+
+ + +
+
+
+ )} +
{startIndex + index + 1} + {item?.Name}{" "} + {item?.Note || "-"} + {item?.Folder?.Name || "OpenSign™ Drive"} + + + {item?.URL ? "Download" : "-"} + - - {item?.URL ? "Download" : "-"} - - {formatRow(item?.ExtUserPtr)} - {item?.Signers ? formatRow(item?.Signers) : "-"} - - {actions?.length > 0 && - actions.map((act, index) => ( - + {formatRow(item?.ExtUserPtr)} + + {item?.Signers ? formatRow(item?.Signers) : "-"} + + {actions?.length > 0 && + actions.map((act, index) => ( + + ))} + {isDeleteModal[item.objectId] && ( + +
+
+ Are you sure you want to delete this document? +
+
+
+ + +
+
+
+ )} + {isShare[item.objectId] && ( + { + setIsShare({}); + setActLoader({}); }} > - - {act?.btnIcon && ( - - )} - - - {act?.btnLabel ? act.btnLabel : "view"} - - - ))} -
+
+ {List.length > docPerPage && ( + <> + {currentPage > 1 && ( + )} - ) : ( - <> )} -
-
- {List.length > docPerPage && ( - <> - {currentPage > 1 && ( - - )} - - )} - {pageNumbers.map((x) => ( - - ))} - {isMoreDocs && ( - - )} - {List.length > docPerPage && ( - <> - {pageNumbers.includes(currentPage + 1) && ( - - )} - - )} -
- {List?.length <= 0 && ( -
-
- img + {pageNumbers.map((x) => ( + + ))} + {isMoreDocs && ( + + )} + {List.length > docPerPage && ( + <> + {pageNumbers.includes(currentPage + 1) && ( + + )} + + )} +
+ {List?.length <= 0 && ( +
+
+ img +
+
No Data Available
-
No Data Available
-
- )} - - - - setIsDocErr(false)} - > -
-

Please add receipent in template!

-
-
+ )} + + + + setIsDocErr(false)} + > +
+

Please add receipent in template!

+
+
+
); };