mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-06 17:57:39 +02:00
Merge branch 'staging' of https://github.com/OpenSignLabs/OpenSign into fix_issue
This commit is contained in:
@@ -13,7 +13,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "1231",
|
||||
btnLabel: "Edit",
|
||||
hoverLabel: "Edit",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-pen",
|
||||
@@ -22,7 +22,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "2142",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
@@ -41,10 +41,11 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "4536",
|
||||
btnLabel: "Sign",
|
||||
btnLabel: "sign",
|
||||
hoverLabel: "Sign",
|
||||
btnColor: "#3ac9d6",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
btnIcon: "fa-solid fa-signature",
|
||||
redirectUrl: "pdfRequestFiles",
|
||||
action: "redirect"
|
||||
}
|
||||
@@ -60,8 +61,8 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "8901",
|
||||
btnLabel: "Share",
|
||||
btnColor: "#3ac9d6",
|
||||
hoverLabel: "Share",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-share",
|
||||
redirectUrl: "",
|
||||
@@ -69,7 +70,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "1588",
|
||||
btnLabel: "View",
|
||||
hoverLabel: "View",
|
||||
btnColor: "#3ac9d6",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
@@ -77,22 +78,30 @@ export default function reportJson(id) {
|
||||
action: "redirect"
|
||||
},
|
||||
{
|
||||
btnId: "1488",
|
||||
btnLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
},
|
||||
{
|
||||
btnId: "1688",
|
||||
btnLabel: "Revoke",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-file-circle-xmark",
|
||||
redirectUrl: "",
|
||||
action: "revoke"
|
||||
btnId: "2234",
|
||||
hoverLabel: "option",
|
||||
btnColor: "transparent",
|
||||
textColor: "black",
|
||||
btnIcon: "fa-solid fa-ellipsis-vertical fa-lg",
|
||||
action: "option",
|
||||
subaction: [
|
||||
{
|
||||
btnId: "1688",
|
||||
btnLabel: "Revoke",
|
||||
hoverLabel: "Revoke",
|
||||
btnIcon: "fa-solid fa-file-circle-xmark",
|
||||
redirectUrl: "",
|
||||
action: "revoke"
|
||||
},
|
||||
{
|
||||
btnId: "1488",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
helpMsg:
|
||||
@@ -106,7 +115,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "1378",
|
||||
btnLabel: "Edit",
|
||||
hoverLabel: "Edit",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
@@ -115,7 +124,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "1278",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
@@ -134,7 +143,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "1458",
|
||||
btnLabel: "View",
|
||||
hoverLabel: "View",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
@@ -143,7 +152,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "1358",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
@@ -162,7 +171,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "1898",
|
||||
btnLabel: "View",
|
||||
hoverLabel: "View",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
@@ -171,7 +180,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "1998",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
@@ -190,21 +199,47 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "1999",
|
||||
btnLabel: "View",
|
||||
hoverLabel: "Share",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-share",
|
||||
redirectUrl: "",
|
||||
action: "share"
|
||||
},
|
||||
{
|
||||
btnId: "1999",
|
||||
hoverLabel: "View",
|
||||
btnColor: "#3ac9d6",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-eye",
|
||||
redirectUrl: "pdfRequestFiles",
|
||||
action: "redirect"
|
||||
},
|
||||
{
|
||||
btnId: "2000",
|
||||
btnLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
btnId: "2234",
|
||||
hoverLabel: "option",
|
||||
btnColor: "transparent",
|
||||
textColor: "black",
|
||||
btnIcon: "fa-solid fa-ellipsis-vertical fa-lg",
|
||||
action: "option",
|
||||
subaction: [
|
||||
{
|
||||
btnId: "6788",
|
||||
btnLabel: "Revoke",
|
||||
hoverLabel: "Revoke",
|
||||
btnIcon: "fa-solid fa-file-circle-xmark",
|
||||
redirectUrl: "",
|
||||
action: "revoke"
|
||||
},
|
||||
{
|
||||
btnId: "2000",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -216,8 +251,9 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "2001",
|
||||
btnLabel: "Sign",
|
||||
btnColor: "#4bd396",
|
||||
btnLabel: "sign",
|
||||
hoverLabel: "Sign",
|
||||
btnColor: "#3ac9d6",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-signature",
|
||||
redirectUrl: "pdfRequestFiles",
|
||||
@@ -233,7 +269,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "2003",
|
||||
btnLabel: "Edit",
|
||||
hoverLabel: "Edit",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-pen",
|
||||
@@ -242,7 +278,7 @@ export default function reportJson(id) {
|
||||
},
|
||||
{
|
||||
btnId: "2004",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
@@ -259,7 +295,7 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "2204",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnColor: "#f55a42",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-trash",
|
||||
@@ -278,7 +314,8 @@ export default function reportJson(id) {
|
||||
actions: [
|
||||
{
|
||||
btnId: "2234",
|
||||
btnLabel: "Create document",
|
||||
btnLabel: "Use",
|
||||
hoverLabel: "Use",
|
||||
btnColor: "#4bd396",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-plus",
|
||||
@@ -286,22 +323,30 @@ export default function reportJson(id) {
|
||||
action: "redirect"
|
||||
},
|
||||
{
|
||||
btnLabel: "Edit",
|
||||
btnId: "2434",
|
||||
btnColor: "#00c9d5",
|
||||
textColor: "white",
|
||||
btnIcon: "fa-solid fa-pen",
|
||||
redirectUrl: "template",
|
||||
action: "redirect"
|
||||
},
|
||||
{
|
||||
btnId: "1834",
|
||||
btnLabel: "Delete",
|
||||
btnColor: "#ff4848",
|
||||
textColor: "white",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
btnId: "2234",
|
||||
hoverLabel: "option",
|
||||
btnColor: "transparent",
|
||||
textColor: "black",
|
||||
btnIcon: "fa-solid fa-ellipsis-vertical fa-lg",
|
||||
action: "option",
|
||||
subaction: [
|
||||
{
|
||||
btnId: "2434",
|
||||
btnLabel: "Edit",
|
||||
hoverLabel: "Edit",
|
||||
btnIcon: "fa-solid fa-pen",
|
||||
redirectUrl: "template",
|
||||
action: "redirect"
|
||||
},
|
||||
{
|
||||
btnId: "1834",
|
||||
btnLabel: "Delete",
|
||||
hoverLabel: "Delete",
|
||||
btnIcon: "fa fa-trash",
|
||||
redirectUrl: "",
|
||||
action: "delete"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
helpMsg:
|
||||
|
||||
@@ -9,18 +9,7 @@ import Alert from "./Alert";
|
||||
import Tooltip from "./Tooltip";
|
||||
import { RWebShare } from "react-web-share";
|
||||
|
||||
const ReportTable = ({
|
||||
ReportName,
|
||||
List,
|
||||
setList,
|
||||
actions,
|
||||
heading,
|
||||
setIsNextRecord,
|
||||
isMoreDocs,
|
||||
docPerPage,
|
||||
form,
|
||||
report_help
|
||||
}) => {
|
||||
const ReportTable = (props) => {
|
||||
const navigate = useNavigate();
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [actLoader, setActLoader] = useState({});
|
||||
@@ -32,18 +21,19 @@ const ReportTable = ({
|
||||
const [isShare, setIsShare] = useState({});
|
||||
const [shareUrls, setShareUrls] = useState([]);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [isOption, setIsOption] = useState({});
|
||||
const [alertMsg, setAlertMsg] = useState({ type: "success", message: "" });
|
||||
const startIndex = (currentPage - 1) * docPerPage;
|
||||
|
||||
const startIndex = (currentPage - 1) * props.docPerPage;
|
||||
const { isMoreDocs, setIsNextRecord } = props;
|
||||
// For loop is used to calculate page numbers visible below table
|
||||
// Initialize pageNumbers using useMemo to avoid unnecessary re-creation
|
||||
const pageNumbers = useMemo(() => {
|
||||
const calculatedPageNumbers = [];
|
||||
for (let i = 1; i <= Math.ceil(List.length / docPerPage); i++) {
|
||||
for (let i = 1; i <= Math.ceil(props.List.length / props.docPerPage); i++) {
|
||||
calculatedPageNumbers.push(i);
|
||||
}
|
||||
return calculatedPageNumbers;
|
||||
}, [List, docPerPage]);
|
||||
}, [props.List, props.docPerPage]);
|
||||
// below useEffect reset currenpage to 1 if user change route
|
||||
useEffect(() => {
|
||||
return () => setCurrentPage(1);
|
||||
@@ -73,8 +63,8 @@ const ReportTable = ({
|
||||
|
||||
// `handleURL` is used to open microapp
|
||||
const handleURL = async (item, act) => {
|
||||
if (ReportName === "Templates") {
|
||||
if (act.btnLabel === "Edit") {
|
||||
if (props.ReportName === "Templates") {
|
||||
if (act.hoverLabel === "Edit") {
|
||||
navigate(`/${act.redirectUrl}/${item.objectId}`);
|
||||
} else {
|
||||
setActLoader({ [`${item.objectId}_${act.btnId}`]: true });
|
||||
@@ -212,13 +202,15 @@ const ReportTable = ({
|
||||
handleShare(item);
|
||||
} else if (act.action === "revoke") {
|
||||
setIsRevoke({ [item.objectId]: true });
|
||||
} else if (act.action === "option") {
|
||||
setIsOption({ [item.objectId]: !isOption[item.objectId] });
|
||||
}
|
||||
};
|
||||
// Get current list
|
||||
const indexOfLastDoc = currentPage * docPerPage;
|
||||
const indexOfFirstDoc = indexOfLastDoc - docPerPage;
|
||||
const indexOfLastDoc = currentPage * props.docPerPage;
|
||||
const indexOfFirstDoc = indexOfLastDoc - props.docPerPage;
|
||||
// `currentLists` is total record render on current page
|
||||
const currentLists = List?.slice(indexOfFirstDoc, indexOfLastDoc);
|
||||
const currentLists = props.List?.slice(indexOfFirstDoc, indexOfLastDoc);
|
||||
|
||||
// Change page
|
||||
const paginateFront = () => setCurrentPage(currentPage + 1);
|
||||
@@ -229,7 +221,7 @@ const ReportTable = ({
|
||||
};
|
||||
|
||||
const handleUserData = (data) => {
|
||||
setList((prevData) => [data, ...prevData]);
|
||||
props.setList((prevData) => [data, ...prevData]);
|
||||
};
|
||||
|
||||
const handleDelete = async (item) => {
|
||||
@@ -243,10 +235,10 @@ const ReportTable = ({
|
||||
const serverUrl = process.env.REACT_APP_SERVERURL
|
||||
? process.env.REACT_APP_SERVERURL
|
||||
: window.location.origin + "/api/app";
|
||||
const cls = clsObj[ReportName] || "contracts_Document";
|
||||
const cls = clsObj[props.ReportName] || "contracts_Document";
|
||||
const url = serverUrl + `/classes/${cls}/`;
|
||||
const body =
|
||||
ReportName === "Contactbook"
|
||||
props.ReportName === "Contactbook"
|
||||
? { IsDeleted: true }
|
||||
: { IsArchive: true };
|
||||
const res = await axios.put(url + item.objectId, body, {
|
||||
@@ -265,8 +257,10 @@ const ReportTable = ({
|
||||
message: "Record deleted successfully!"
|
||||
});
|
||||
setTimeout(() => setIsAlert(false), 1500);
|
||||
const upldatedList = List.filter((x) => x.objectId !== item.objectId);
|
||||
setList(upldatedList);
|
||||
const upldatedList = props.List.filter(
|
||||
(x) => x.objectId !== item.objectId
|
||||
);
|
||||
props.setList(upldatedList);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("err", err);
|
||||
@@ -335,8 +329,10 @@ const ReportTable = ({
|
||||
message: "Record revoked successfully!"
|
||||
});
|
||||
setTimeout(() => setIsAlert(false), 1500);
|
||||
const upldatedList = List.filter((x) => x.objectId !== item.objectId);
|
||||
setList(upldatedList);
|
||||
const upldatedList = props.List.filter(
|
||||
(x) => x.objectId !== item.objectId
|
||||
);
|
||||
props.setList(upldatedList);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -364,20 +360,20 @@ const ReportTable = ({
|
||||
{isAlert && <Alert type={alertMsg.type}>{alertMsg.message}</Alert>}
|
||||
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
|
||||
<div className="font-light">
|
||||
{ReportName}{" "}
|
||||
{report_help && (
|
||||
{props.ReportName}{" "}
|
||||
{props.report_help && (
|
||||
<span className="text-xs md:text-[13px] font-normal">
|
||||
<Tooltip message={report_help} />
|
||||
<Tooltip message={props.report_help} />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{ReportName === "Templates" && (
|
||||
{props.ReportName === "Templates" && (
|
||||
<i
|
||||
onClick={() => navigate("/form/template")}
|
||||
className="fa-solid fa-square-plus text-sky-400 text-[25px]"
|
||||
></i>
|
||||
)}
|
||||
{form && (
|
||||
{props.form && (
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
onClick={() => handleContactFormModal()}
|
||||
@@ -389,36 +385,36 @@ const ReportTable = ({
|
||||
<table className="table-auto w-full border-collapse">
|
||||
<thead className="text-[14px]">
|
||||
<tr className="border-y-[1px]">
|
||||
{heading?.map((item, index) => (
|
||||
{props.heading?.map((item, index) => (
|
||||
<React.Fragment key={index}>
|
||||
<th className="px-4 py-2 font-thin">{item}</th>
|
||||
</React.Fragment>
|
||||
))}
|
||||
{actions?.length > 0 && (
|
||||
{props.actions?.length > 0 && (
|
||||
<th className="px-4 py-2 font-thin">Action</th>
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-[12px]">
|
||||
{List?.length > 0 && (
|
||||
{props.List?.length > 0 && (
|
||||
<>
|
||||
{currentLists.map((item, index) =>
|
||||
ReportName === "Contactbook" ? (
|
||||
props.ReportName === "Contactbook" ? (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
{props.heading.includes("Sr.No") && (
|
||||
<td className="px-4 py-2">{startIndex + index + 1}</td>
|
||||
)}
|
||||
<td className="px-4 py-2 font-semibold">{item?.Name} </td>
|
||||
<td className="px-4 py-2">{item?.Email || "-"}</td>
|
||||
<td className="px-4 py-2">{item?.Phone || "-"}</td>
|
||||
<td className="px-3 py-2 text-white grid grid-cols-2">
|
||||
{actions?.length > 0 &&
|
||||
actions.map((act, index) => (
|
||||
{props.actions?.length > 0 &&
|
||||
props.actions.map((act, index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() => handleActionBtn(act, item)}
|
||||
className={`mb-1 flex justify-center items-center gap-1 px-2 py-1 rounded shadow`}
|
||||
title={act.btnLabel}
|
||||
title={act.hoverLabel}
|
||||
style={{
|
||||
backgroundColor: act.btnColor
|
||||
? act.btnColor
|
||||
@@ -467,16 +463,16 @@ const ReportTable = ({
|
||||
</tr>
|
||||
) : (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
{props.heading.includes("Sr.No") && (
|
||||
<td className="px-4 py-2">{startIndex + index + 1}</td>
|
||||
)}
|
||||
<td className="px-4 py-2 font-semibold w-56">
|
||||
{item?.Name}{" "}
|
||||
</td>
|
||||
{heading.includes("Note") && (
|
||||
{props.heading.includes("Note") && (
|
||||
<td className="px-4 py-2">{item?.Note || "-"}</td>
|
||||
)}
|
||||
{heading.includes("Folder") && (
|
||||
{props.heading.includes("Folder") && (
|
||||
<td className="px-4 py-2">
|
||||
{item?.Folder?.Name || "OpenSign™ Drive"}
|
||||
</td>
|
||||
@@ -500,14 +496,18 @@ const ReportTable = ({
|
||||
<td className="px-4 py-2">
|
||||
{item?.Signers ? formatRow(item?.Signers) : "-"}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-white grid grid-cols-2 gap-1">
|
||||
{actions?.length > 0 &&
|
||||
actions.map((act, index) => (
|
||||
<td className="px-2 py-2 text-white flex flex-row gap-x-2 gap-y-1 justify-center items-center">
|
||||
{props.actions?.length > 0 &&
|
||||
props.actions.map((act, index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() => handleActionBtn(act, item)}
|
||||
className={`w-[25px] h-[25px] flex justify-center items-center rounded shadow`}
|
||||
title={act.btnLabel}
|
||||
className={`${
|
||||
act.action === "option" ? "" : "rounded shadow"
|
||||
} ${
|
||||
act.btnLabel ? "py-[3px] px-1.5" : "py-1.5 px-2"
|
||||
} relative text-center flex items-center justify-center focus:outline-none`}
|
||||
title={act.hoverLabel}
|
||||
style={{
|
||||
backgroundColor: act.btnColor
|
||||
? act.btnColor
|
||||
@@ -516,6 +516,33 @@ const ReportTable = ({
|
||||
}}
|
||||
>
|
||||
<i className={act.btnIcon}></i>
|
||||
{act.btnLabel && (
|
||||
<span className="ml-[4px] uppercase font-medium">
|
||||
{act.btnLabel}
|
||||
</span>
|
||||
)}
|
||||
{isOption[item.objectId] &&
|
||||
act.action === "option" && (
|
||||
<div className="absolute -right-2 top-5 bg-white rounded shadow z-[20] overflow-hidden">
|
||||
{act.subaction?.map((subact) => (
|
||||
<div
|
||||
key={subact.btnId}
|
||||
className="hover:bg-gray-300 cursor-pointer px-2 py-1.5 flex justify-start items-center text-black"
|
||||
onClick={() =>
|
||||
handleActionBtn(subact, item)
|
||||
}
|
||||
title={subact.hoverLabel}
|
||||
>
|
||||
<i className={subact.btnIcon}></i>
|
||||
{subact.btnLabel && (
|
||||
<span className="ml-[4px] text-xs capitalize">
|
||||
{subact.btnLabel}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
{isDeleteModal[item.objectId] && (
|
||||
@@ -637,7 +664,7 @@ const ReportTable = ({
|
||||
</tbody>
|
||||
</table>
|
||||
<div className="flex flex-wrap items-center gap-2 p-2 ">
|
||||
{List.length > docPerPage && (
|
||||
{props.List.length > props.docPerPage && (
|
||||
<>
|
||||
{currentPage > 1 && (
|
||||
<button
|
||||
@@ -661,7 +688,7 @@ const ReportTable = ({
|
||||
{isMoreDocs && (
|
||||
<button className="text-black rounded px-1 py-2">...</button>
|
||||
)}
|
||||
{List.length > docPerPage && (
|
||||
{props.List.length > props.docPerPage && (
|
||||
<>
|
||||
{pageNumbers.includes(currentPage + 1) && (
|
||||
<button
|
||||
@@ -674,7 +701,7 @@ const ReportTable = ({
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{List?.length <= 0 && (
|
||||
{props.List?.length <= 0 && (
|
||||
<div className="flex flex-col items-center justify-center w-full bg-white rounded py-4">
|
||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||
<img
|
||||
|
||||
+118
-86
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
||||
import axios from 'axios';
|
||||
import { pdflibAddPlaceholder } from './customSignPdf/pdflibplaceholder.min.js';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import { saveFileUsage } from '../../../Utils.js';
|
||||
import { replaceMailVaribles, saveFileUsage } from '../../../Utils.js';
|
||||
import GenerateCertificate from './GenerateCertificate.js';
|
||||
const serverUrl = process.env.SERVER_URL,
|
||||
APPID = process.env.APP_ID,
|
||||
@@ -20,18 +20,18 @@ async function uploadFile(e, a) {
|
||||
}
|
||||
async function updateDoc(t, s, r, i, o, n) {
|
||||
try {
|
||||
var d = {
|
||||
var l = {
|
||||
UserPtr: { __type: 'Pointer', className: n, objectId: r },
|
||||
SignedUrl: s,
|
||||
Activity: 'Signed',
|
||||
ipAddress: i,
|
||||
};
|
||||
let e;
|
||||
var l = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, d] : [d]).filter(
|
||||
var d = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, l] : [l]).filter(
|
||||
e => 'Signed' === e.Activity
|
||||
);
|
||||
let a = !1;
|
||||
!((o.Signers && 0 < o.Signers.length && l.length !== o.Signers.length) || !(a = !0));
|
||||
!((o.Signers && 0 < o.Signers.length && d.length !== o.Signers.length) || !(a = !0));
|
||||
var c = { SignedUrl: s, AuditTrail: e, IsCompleted: a };
|
||||
await axios.put(serverUrl + '/classes/contracts_Document/' + t, c, {
|
||||
headers: {
|
||||
@@ -47,23 +47,62 @@ async function updateDoc(t, s, r, i, o, n) {
|
||||
}
|
||||
async function sendCompletedMail(e) {
|
||||
var a = e.url,
|
||||
t = e.sender,
|
||||
s = e.pdfName,
|
||||
r = e.receiver,
|
||||
e = {
|
||||
extUserId: e.extUserId,
|
||||
url: a,
|
||||
from: 'OpenSign™',
|
||||
recipient: r,
|
||||
subject: `Document ${s} has been signed by all parties`,
|
||||
pdfName: s,
|
||||
html:
|
||||
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=https://qikinnovation.ams3.digitaloceanspaces.com/logo.png height='50' style='padding:20px'/> </div><div style='padding:2px;font-family:system-ui; background-color: #47a3ad;'> <p style='font-size:20px;font-weight:400;color:white;padding-left:20px',> Document sign successfully</p></div><div><p style='padding:20px;font-family:system-ui;font-size:14px'>All parties have successfully signed the document" +
|
||||
s +
|
||||
'. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender ' +
|
||||
t.Mail +
|
||||
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
|
||||
};
|
||||
t = e.doc,
|
||||
s = e.doc.ExtUserPtr,
|
||||
r = t.Name,
|
||||
i = s.Email;
|
||||
let o = `Document "${r}" has been signed by all parties`,
|
||||
n =
|
||||
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=https://qikinnovation.ams3.digitaloceanspaces.com/logo.png height='50' style='padding:20px'/> </div><div style='padding:2px;font-family:system-ui; background-color: #47a3ad;'> <p style='font-size:20px;font-weight:400;color:white;padding-left:20px',> Document signed successfully</p></div><div><p style='padding:20px;font-family:system-ui;font-size:14px'>All parties have successfully signed the document " +
|
||||
`<b>"${r}"</b>` +
|
||||
'. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender ' +
|
||||
s.Email +
|
||||
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>';
|
||||
if (e?.isCustomMail)
|
||||
try {
|
||||
var l,
|
||||
d,
|
||||
c,
|
||||
p,
|
||||
m,
|
||||
g = new Parse.Query('partners_Tenant');
|
||||
g.equalTo('UserId', { __type: 'Pointer', className: '_User', objectId: s.UserId.objectId });
|
||||
const u = await g.first();
|
||||
u &&
|
||||
((l = JSON.parse(JSON.stringify(u)))?.CompletionSubject && (o = l?.CompletionSubject),
|
||||
l?.CompletionBody && (n = l?.CompletionBody),
|
||||
(d = t.ExpiryDate.iso),
|
||||
(c = new Date(d).toLocaleDateString('en-US', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
})),
|
||||
(p = {
|
||||
document_title: r,
|
||||
sender_name: s.Name,
|
||||
sender_mail: s.Email,
|
||||
sender_phone: s.Phone,
|
||||
receiver_name: s.Name,
|
||||
receiver_email: s.Email,
|
||||
receiver_phone: s.Phone,
|
||||
expiry_date: c,
|
||||
company_name: s.Company,
|
||||
}),
|
||||
(m = replaceMailVaribles(o, n, p)),
|
||||
(o = m.subject),
|
||||
(n = m.body));
|
||||
} catch (e) {
|
||||
console.log('error in fetch tenant in signpdf', e.message);
|
||||
}
|
||||
e = {
|
||||
extUserId: s.objectId,
|
||||
url: a,
|
||||
from: 'OpenSign™',
|
||||
recipient: i,
|
||||
subject: o,
|
||||
pdfName: r,
|
||||
html: n,
|
||||
};
|
||||
await axios.post(serverUrl + '/functions/sendmailv3', e, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -134,6 +173,7 @@ async function PDF(o) {
|
||||
try {
|
||||
var n = o.params.docId,
|
||||
e = o.params.userId,
|
||||
l = o.params.isCustomCompletionMail,
|
||||
d = await axios.get(
|
||||
serverUrl + '/classes/contracts_Document/' + n + '?include=ExtUserPtr,Signers',
|
||||
{
|
||||
@@ -144,33 +184,33 @@ async function PDF(o) {
|
||||
},
|
||||
}
|
||||
),
|
||||
l = await axios.get(serverUrl + '/users/me', {
|
||||
c = await axios.get(serverUrl + '/users/me', {
|
||||
headers: {
|
||||
'X-Parse-Application-Id': APPID,
|
||||
'X-Parse-Session-Token': o.headers.sessiontoken,
|
||||
},
|
||||
});
|
||||
if (!l.data || !l.data.objectId) return { status: 'error', message: 'This user not allowed!' };
|
||||
if (!c.data || !c.data.objectId) return { status: 'error', message: 'This user not allowed!' };
|
||||
{
|
||||
var a,
|
||||
t,
|
||||
s,
|
||||
c = JSON.stringify({ objectId: e });
|
||||
p = JSON.stringify({ objectId: e });
|
||||
let r, i;
|
||||
i = e
|
||||
? (a = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
|
||||
? (a = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + p, {
|
||||
headers: {
|
||||
'X-Parse-Application-Id': APPID,
|
||||
'X-Parse-Session-Token': o.headers.sessiontoken,
|
||||
},
|
||||
})).data && 0 < a.data.results.length
|
||||
? ((r = a), 'contracts_Contactbook')
|
||||
: ((r = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
|
||||
: ((r = await axios.get(serverUrl + '/classes/contracts_Users?where=' + p, {
|
||||
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
|
||||
})),
|
||||
'contracts_Users')
|
||||
: ((t = JSON.stringify({
|
||||
UserId: { __type: 'Pointer', className: '_User', objectId: l.data.objectId },
|
||||
UserId: { __type: 'Pointer', className: '_User', objectId: c.data.objectId },
|
||||
})),
|
||||
(s = await axios.get(serverUrl + '/classes/contracts_Users?where=' + t, {
|
||||
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
|
||||
@@ -183,13 +223,13 @@ async function PDF(o) {
|
||||
},
|
||||
})),
|
||||
'contracts_Contactbook'));
|
||||
var p = r.data.results[0].Name,
|
||||
m = r.data.results[0].Email;
|
||||
var m = r.data.results[0].Name,
|
||||
g = r.data.results[0].Email;
|
||||
if (!o.params.pdfFile) return { status: 'error', message: 'Pdf file not present!' };
|
||||
{
|
||||
let e = Buffer.from(o.params.pdfFile, 'base64');
|
||||
var g = process.env.PFX_BASE64,
|
||||
u = Buffer.from(g, 'base64'),
|
||||
var u = process.env.PFX_BASE64,
|
||||
h = Buffer.from(u, 'base64'),
|
||||
f = {
|
||||
UserPtr: { __type: 'Pointer', className: i, objectId: r.data.results[0].objectId },
|
||||
SignedUrl: '',
|
||||
@@ -197,104 +237,96 @@ async function PDF(o) {
|
||||
ipAddress: o.headers['x-real-ip'],
|
||||
};
|
||||
let a;
|
||||
var h = (a =
|
||||
var P = (a =
|
||||
d.data.AuditTrail && 0 < d.data.AuditTrail.length
|
||||
? [...d.data.AuditTrail, f]
|
||||
: [f]).filter(e => 'Signed' === e.Activity);
|
||||
let t = !1;
|
||||
!(
|
||||
(d.data.Signers && 0 < d.data.Signers.length && h.length !== d.data.Signers.length) ||
|
||||
(d.data.Signers && 0 < d.data.Signers.length && P.length !== d.data.Signers.length) ||
|
||||
!(t = !0)
|
||||
);
|
||||
var P,
|
||||
y,
|
||||
var y,
|
||||
b,
|
||||
v,
|
||||
U,
|
||||
b,
|
||||
I,
|
||||
w = `exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
|
||||
A = './exports/' + w;
|
||||
w,
|
||||
D = `exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
|
||||
S = './exports/' + D;
|
||||
let s = e.length;
|
||||
s = (
|
||||
t
|
||||
? ((P = d.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
|
||||
? ((y = d.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
|
||||
(e =
|
||||
P && 0 < P.length
|
||||
? ((y = await PDFDocument.load(e)),
|
||||
y && 0 < y.length
|
||||
? ((b = await PDFDocument.load(e)),
|
||||
pdflibAddPlaceholder({
|
||||
pdfDoc: y,
|
||||
reason: 'Digitally signed by OpenSign for ' + P?.join(', '),
|
||||
pdfDoc: b,
|
||||
reason: 'Digitally signed by OpenSign for ' + y?.join(', '),
|
||||
location: 'n/a',
|
||||
signatureLength: 15e3,
|
||||
}),
|
||||
(v = await y.save()),
|
||||
(v = await b.save()),
|
||||
Buffer.from(v))
|
||||
: ((U = await PDFDocument.load(e)),
|
||||
pdflibAddPlaceholder({
|
||||
pdfDoc: U,
|
||||
reason: 'Digitally signed by OpenSign for ' + p + ' <' + m + '>',
|
||||
reason: 'Digitally signed by OpenSign for ' + m + ' <' + g + '>',
|
||||
location: 'n/a',
|
||||
signatureLength: 15e3,
|
||||
}),
|
||||
(b = await U.save()),
|
||||
Buffer.from(b))),
|
||||
(I = await new SignPDF(e, u).signPDF()),
|
||||
fs.writeFileSync(A, I),
|
||||
I)
|
||||
: (fs.writeFileSync(A, e), e)
|
||||
(I = await U.save()),
|
||||
Buffer.from(I))),
|
||||
(w = await new SignPDF(e, h).signPDF()),
|
||||
fs.writeFileSync(S, w),
|
||||
w)
|
||||
: (fs.writeFileSync(S, e), e)
|
||||
).length;
|
||||
var D,
|
||||
S,
|
||||
var _,
|
||||
A,
|
||||
x,
|
||||
E,
|
||||
_,
|
||||
j,
|
||||
k,
|
||||
F,
|
||||
C,
|
||||
T,
|
||||
N,
|
||||
C = await uploadFile(w, A);
|
||||
if (C && C.imageUrl)
|
||||
N = await uploadFile(D, S);
|
||||
if (N && N.imageUrl)
|
||||
return (
|
||||
(D = await updateDoc(
|
||||
(_ = await updateDoc(
|
||||
o.params.docId,
|
||||
C.imageUrl,
|
||||
N.imageUrl,
|
||||
r.data.results[0].objectId,
|
||||
o.headers['x-real-ip'],
|
||||
d.data,
|
||||
i
|
||||
)),
|
||||
sendDoctoWebhook(d, C.imageUrl, 'signed', r?.data.results?.[0]),
|
||||
saveFileUsage(s, C.imageUrl, l.data.objectId),
|
||||
D &&
|
||||
D.isCompleted &&
|
||||
((S = {
|
||||
url: C.imageUrl,
|
||||
sender: { Mail: d.data.ExtUserPtr.Email, Name: 'OpenSign™' },
|
||||
pdfName: d.data.Name,
|
||||
receiver: d.data.ExtUserPtr.Email,
|
||||
extUserId: d.data.ExtUserPtr.objectId,
|
||||
}),
|
||||
(x = { ...d.data, AuditTrail: D.AuditTrail }),
|
||||
(E = await GenerateCertificate(x)),
|
||||
(_ = await PDFDocument.load(E)),
|
||||
sendDoctoWebhook(d, N.imageUrl, 'signed', r?.data.results?.[0]),
|
||||
saveFileUsage(s, N.imageUrl, c.data.objectId),
|
||||
_ &&
|
||||
_.isCompleted &&
|
||||
((A = { ...d.data, AuditTrail: _.AuditTrail }),
|
||||
(x = await GenerateCertificate(A)),
|
||||
(E = await PDFDocument.load(x)),
|
||||
pdflibAddPlaceholder({
|
||||
pdfDoc: _,
|
||||
pdfDoc: E,
|
||||
reason: 'Digitally signed by OpenSign.',
|
||||
location: 'n/a',
|
||||
signatureLength: 15e3,
|
||||
}),
|
||||
(j = await _.save()),
|
||||
(j = await E.save()),
|
||||
(k = Buffer.from(j)),
|
||||
(F = await new SignPDF(k, u).signPDF()),
|
||||
(F = await new SignPDF(k, h).signPDF()),
|
||||
fs.writeFileSync('./exports/certificate.pdf', F),
|
||||
(N = {
|
||||
CertificateUrl: (T = await uploadFile(
|
||||
(T = {
|
||||
CertificateUrl: (C = await uploadFile(
|
||||
'certificate.pdf',
|
||||
'./exports/certificate.pdf'
|
||||
)).imageUrl,
|
||||
}),
|
||||
await axios.put(serverUrl + '/classes/contracts_Document/' + n, N, {
|
||||
await axios.put(serverUrl + '/classes/contracts_Document/' + n, T, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': APPID,
|
||||
@@ -303,13 +335,13 @@ async function PDF(o) {
|
||||
}),
|
||||
d.data.IsSendMail && !1 === d.data.IsSendMail
|
||||
? console.log("don't send mail")
|
||||
: sendCompletedMail(S),
|
||||
saveFileUsage(k.length, T.imageUrl, l.data.objectId),
|
||||
sendDoctoWebhook(d, C.imageUrl, 'completed')),
|
||||
fs.unlinkSync(A),
|
||||
console.log('New Signed PDF created called: ' + A),
|
||||
'success' === D.message
|
||||
? { status: 'success', data: C.imageUrl }
|
||||
: sendCompletedMail({ url: N.imageUrl, isCustomMail: l, doc: d.data }),
|
||||
saveFileUsage(k.length, C.imageUrl, c.data.objectId),
|
||||
sendDoctoWebhook(d, N.imageUrl, 'completed')),
|
||||
fs.unlinkSync(S),
|
||||
console.log('New Signed PDF created called: ' + S),
|
||||
'success' === _.message
|
||||
? { status: 'success', data: N.imageUrl }
|
||||
: { status: 'error', message: 'Please provide required parameters!' }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user