diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js
index 364b0af2d..f39898594 100644
--- a/apps/OpenSign/src/json/ReportJson.js
+++ b/apps/OpenSign/src/json/ReportJson.js
@@ -1,11 +1,13 @@
export default function reportJson(id) {
// console.log("json ", json);
-
+ const head = ["Sr.No", "Name", "Note", "Folder", "File", "Owner", "Signers"];
+ const contactbook = ["Sr.No", "Name", "Email", "Phone"];
switch (id) {
// draft documents report
case "ByHuevtCFY":
return {
reportName: "Draft Documents",
+ heading: head,
actions: [
{
btnLabel: "sign",
@@ -21,6 +23,7 @@ export default function reportJson(id) {
case "4Hhwbp482K":
return {
reportName: "Need your sign",
+ heading: head,
actions: [
{
btnLabel: "sign",
@@ -36,6 +39,7 @@ export default function reportJson(id) {
case "1MwEuxLEkF":
return {
reportName: "In-progress documents",
+ heading: head,
actions: [
{
btnLabel: "View",
@@ -51,6 +55,7 @@ export default function reportJson(id) {
case "kQUoW4hUXz":
return {
reportName: "Completed Documents",
+ heading: head,
actions: [
{
btnLabel: "View",
@@ -66,6 +71,7 @@ export default function reportJson(id) {
case "UPr2Fm5WY3":
return {
reportName: "Declined Documents",
+ heading: head,
actions: [
{
btnLabel: "View",
@@ -81,6 +87,7 @@ export default function reportJson(id) {
case "zNqBHXHsYH":
return {
reportName: "Expired Documents",
+ heading: head,
actions: [
{
btnLabel: "View",
@@ -96,6 +103,7 @@ export default function reportJson(id) {
case "d9k3UfYHBc":
return {
reportName: "Recently sent for signatures",
+ heading: head,
actions: [
{
btnLabel: "View",
@@ -111,6 +119,7 @@ export default function reportJson(id) {
case "5Go51Q7T8r":
return {
reportName: "Recent signature requests",
+ heading: head,
actions: [
{
btnLabel: "Sign",
@@ -126,6 +135,7 @@ export default function reportJson(id) {
case "kC5mfynCi4":
return {
reportName: "Drafts",
+ heading: head,
actions: [
{
btnLabel: "sign",
@@ -137,6 +147,20 @@ export default function reportJson(id) {
}
]
};
+ // contactbook report
+ case "5KhaPr482K":
+ return {
+ reportName: "Contactbook",
+ heading: contactbook,
+ actions: [
+ {
+ btnLabel: "",
+ btnColor: "#f55a42",
+ textColor: "white",
+ btnIcon: "fa-solid fa-trash"
+ }
+ ]
+ };
default:
return null;
}
diff --git a/apps/OpenSign/src/layout/HomeLayout.js b/apps/OpenSign/src/layout/HomeLayout.js
index f2df02822..5583df9c5 100644
--- a/apps/OpenSign/src/layout/HomeLayout.js
+++ b/apps/OpenSign/src/layout/HomeLayout.js
@@ -9,7 +9,7 @@ import { useSelector } from "react-redux";
import Parse from "parse";
const HomeLayout = ({ children }) => {
const { width } = useWindowSize();
- const [isOpen, setIsOpen] = useState(false);
+ const [isOpen, setIsOpen] = useState(true);
const arr = useSelector((state) => state.TourSteps);
// reactour state
@@ -19,13 +19,11 @@ const HomeLayout = ({ children }) => {
const [tourConfigs, setTourConfigs] = useState([]);
const showSidebar = () => {
- setIsOpen(!isOpen);
+ setIsOpen(value => !value);
};
useEffect(() => {
if (width && width <= 768) {
setIsOpen(false);
- } else {
- setIsOpen(true);
}
}, [width]);
diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js
index 676230a25..0be8d98ca 100644
--- a/apps/OpenSign/src/primitives/GetReportDisplay.js
+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js
@@ -1,19 +1,23 @@
import React, { useState, useEffect, useMemo } from "react";
import pad from "../assets/images/pad.svg";
import { useNavigate } from "react-router-dom";
-
+import axios from "axios";
+import "../styles/report.css";
const ReportTable = ({
ReportName,
List,
+ setList,
actions,
+ heading,
setIsNextRecord,
isMoreDocs,
docPerPage
}) => {
const navigate = useNavigate();
const [currentPage, setCurrentPage] = useState(1);
- // const pageNumbers = [];
-
+ const [actLoader, setActLoader] = useState({});
+ const [isAlert, setIsAlert] = useState(false);
+ const [isErr, setIsErr] = useState(false);
// For loop is used to calculate page numbers visible below table
// Initialize pageNumbers using useMemo to avoid unnecessary re-creation
const pageNumbers = useMemo(() => {
@@ -57,8 +61,34 @@ const ReportTable = ({
localStorage.setItem("rowlevel", JSON.stringify(item));
// localStorage.setItem("rowlevelMicro");
};
- const handlebtn = () => {
- console.log("clicked");
+ const handlebtn = async (item) => {
+ if (ReportName === "Contactbook") {
+ setActLoader({ [item.objectId]: true });
+ try {
+ const url =
+ process.env.REACT_APP_SERVERURL + "/classes/contracts_Contactbook/";
+ const body = { IsDeleted: true };
+ const res = await axios.put(url + item.objectId, body, {
+ headers: {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": localStorage.getItem("AppID12"),
+ "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ }
+ });
+ // console.log("Res ", res.data);
+ if (res.data && res.data.updatedAt) {
+ setActLoader({});
+ setIsAlert(true);
+ const upldatedList = List.filter((x) => x.objectId !== item.objectId);
+ setList(upldatedList);
+ }
+ } catch (err) {
+ console.log("err", err);
+ setIsAlert(true);
+ setIsErr(true);
+ setActLoader({});
+ }
+ }
};
// Get current list
@@ -73,17 +103,27 @@ const ReportTable = ({
return (
+ {isAlert && (
+
setIsAlert(false)}
+ >
+ {isErr
+ ? "Something went wrong, Please try again later!"
+ : "Record deleted successfully!"}
+
+ )}
+
{ReportName}
- Sr.No
- Name
- Note
- Folder
- File
- Owner
- Signers
+ {heading?.map((item, index) => (
+
+ {item}
+
+ ))}
{actions?.length > 0 && (
Action
)}
@@ -92,61 +132,115 @@ const ReportTable = ({
{List?.length > 0 ? (
<>
- {currentLists.map((item, index) => (
-
- {index + 1}
- {item?.Name}
- {item?.Note || "-"}
-
- {item?.Folder?.Name || "OpenSignDrive"}
-
-
-
- {item?.URL ? "Download" : "-"}
-
-
+ {currentLists.map((item, index) =>
+ ReportName === "Contactbook" ? (
+
+ {index + 1}
+ {item?.Name}
+ {item?.Email || "-"}
+ {item?.Phone || "-"}
+
+ {actions?.length > 0 &&
+ actions.map((act, index) => (
+
+ act?.redirectUrl
+ ? handlemicroapp(item, act.redirectUrl)
+ : handlebtn(item)
+ }
+ className={`flex justify-center items-center gap-1 px-2 py-1 rounded shadow`}
+ style={{
+ backgroundColor: act.btnColor
+ ? act.btnColor
+ : "#3ac9d6",
+ color: act?.textColor ? act?.textColor : "white"
+ }}
+ >
+
+ {act?.btnIcon && (
+
+ )}
+
+ {act?.btnLabel && (
+
+ {act?.btnLabel ? act.btnLabel : "View"}
+
+ )}
+
+ ))}
+
+
+ ) : (
+
+ {index + 1}
+ {item?.Name}
+ {item?.Note || "-"}
+
+ {item?.Folder?.Name || "OpenSignDrive"}
+
+
+
+ {item?.URL ? "Download" : "-"}
+
+
- {formatRow(item?.ExtUserPtr)}
-
- {item?.Signers ? formatRow(item?.Signers) : "-"}
-
-
- {actions?.length > 0 &&
- actions.map((act, index) => (
-
- act?.redirectUrl
- ? handlemicroapp(item, act.redirectUrl)
- : handlebtn(item)
- }
- className={`flex justify-center items-center w-full gap-1 px-2 py-1 rounded shadow`}
- style={{
- backgroundColor: act.btnColor
- ? act.btnColor
- : "#3ac9d6",
- color: act?.textColor ? act?.textColor : "white"
- }}
- >
-
- {act?.btnIcon && }
-
-
- {act?.btnLabel ? act.btnLabel : "view"}
-
-
- // )
- ))}
-
-
- ))}
+ {formatRow(item?.ExtUserPtr)}
+
+ {item?.Signers ? formatRow(item?.Signers) : "-"}
+
+
+ {actions?.length > 0 &&
+ actions.map((act, index) => (
+
+ act?.redirectUrl
+ ? handlemicroapp(item, act.redirectUrl)
+ : handlebtn(item)
+ }
+ className={`flex justify-center items-center w-full gap-1 px-2 py-1 rounded shadow`}
+ style={{
+ backgroundColor: act.btnColor
+ ? act.btnColor
+ : "#3ac9d6",
+ color: act?.textColor ? act?.textColor : "white"
+ }}
+ >
+
+ {act?.btnIcon && (
+
+ )}
+
+
+ {act?.btnLabel ? act.btnLabel : "view"}
+
+
+ // )
+ ))}
+
+
+ )
+ )}
>
) : (
<>>
diff --git a/apps/OpenSign/src/routes/Dashboard.js b/apps/OpenSign/src/routes/Dashboard.js
index 8c102e2e0..2bc3d9bc7 100644
--- a/apps/OpenSign/src/routes/Dashboard.js
+++ b/apps/OpenSign/src/routes/Dashboard.js
@@ -2,11 +2,12 @@ import React, { useState, useEffect } from "react";
import Parse from "parse";
import "../styles/loader.css";
import GetDashboard from "../components/dashboard/GetDashboard";
-import { Navigate, useParams } from "react-router-dom";
+import { useNavigate, useParams } from "react-router-dom";
import Title from "../components/Title";
import { save_tourSteps } from "../redux/actions";
import { connect } from "react-redux";
const Dashboard = (props) => {
+ const navigate = useNavigate();
const { id } = useParams();
const [dashboard, setdashboard] = useState([]);
const [classnameArray, setclassnameArray] = useState([]);
@@ -15,6 +16,19 @@ const Dashboard = (props) => {
const [parseAppId] = useState(localStorage.getItem("parseAppId"));
const [defaultQuery, setDefaultQuery] = useState("");
+ useEffect(() => {
+ if (localStorage.getItem("accesstoken")) {
+ if (id !== undefined) {
+ getDashboard(id);
+ } else {
+ getDashboard(localStorage.getItem("PageLanding"));
+ }
+ } else {
+ navigate("/", { replace: true });
+ }
+ // eslint-disable-next-line
+ }, [id]);
+
const getDashboard = async (id) => {
setloading(true);
try {
@@ -93,20 +107,6 @@ const Dashboard = (props) => {
}
};
- useEffect(() => {
- if (id !== undefined) {
- getDashboard(id);
- } else {
- getDashboard(localStorage.getItem("PageLanding"));
- }
-
- // eslint-disable-next-line
- }, [id]);
-
- if (localStorage.getItem("accesstoken") === "" || null) {
- return ;
- }
-
let _dash = (
{
const [isLoader, setIsLoader] = useState(true);
const [reportName, setReportName] = useState("");
const [actions, setActions] = useState([]);
+ const [heading, setHeading] = useState([]);
const [isNextRecord, setIsNextRecord] = useState(false);
const [isMoreDocs, setIsMoreDocs] = useState(true);
const abortController = new AbortController();
@@ -47,6 +48,7 @@ const Report = () => {
const json = reportJson(id);
if (json) {
setActions(json.actions);
+ setHeading(json.heading);
setReportName(json.reportName);
Parse.serverURL = localStorage.getItem("BaseUrl12");
Parse.initialize(localStorage.getItem("AppID12"));
@@ -146,7 +148,9 @@ const Report = () => {
{
+ const className = 'w_menu';
+ const userMenu = new Parse.Query(className);
+ const updateUserMenu = await userMenu.get('H9vRfEYKhT');
+ updateUserMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDrive™',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ {
+ icon: 'fa-solid fa-address-book',
+ title: 'Contactbook',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '5KhaPr482K',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ ],
+ },
+ ]);
+
+ const AdminMenu = new Parse.Query(className);
+ const updateAdminMenu = await AdminMenu.get('VPh91h0ZHk');
+ updateAdminMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDrive™',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ {
+ icon: 'fa-solid fa-address-book',
+ title: 'Contactbook',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '5KhaPr482K',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ {
+ icon: 'far fa-user',
+ title: 'Add User',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'lM0xRnM3iE',
+ },
+ ],
+ },
+ ]);
+ // TODO: Set the schema here
+ // Example:
+ // schema.addString('name').addNumber('cash');
+ const batch = [updateUserMenu, updateAdminMenu];
+ return Parse.Object.saveAll(batch, { useMasterKey: true });
+};
+
+/**
+ *
+ * @param {Parse} Parse
+ */
+exports.down = async Parse => {
+ // TODO: set className here
+ const className = 'w_menu';
+ const userMenu = new Parse.Query(className);
+ const revertUserMenu = await userMenu.get('H9vRfEYKhT');
+ revertUserMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDrive™',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ ],
+ },
+ ]);
+
+ const adminMenu = new Parse.Query(className);
+ const revertAdminMenu = await adminMenu.get('VPh91h0ZHk');
+ revertAdminMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDrive™',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ {
+ icon: 'far fa-user',
+ title: 'Add User',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'lM0xRnM3iE',
+ },
+ ],
+ },
+ ]);
+ // TODO: Set the schema here
+ // Example:
+ // schema.addString('name').addNumber('cash');
+ const batch = [revertUserMenu, revertAdminMenu];
+ return Parse.Object.saveAll(batch, { useMasterKey: true });
+};
diff --git a/apps/OpenSignServer/index.js b/apps/OpenSignServer/index.js
index 760b6df91..819940954 100644
--- a/apps/OpenSignServer/index.js
+++ b/apps/OpenSignServer/index.js
@@ -18,6 +18,7 @@ import FSFilesAdapter from 'parse-server-fs-adapter';
import AWS from 'aws-sdk';
import { app as customRoute } from './cloud/customRoute/customApp.js';
import { exec } from 'child_process';
+import { createTransport } from 'nodemailer';
const spacesEndpoint = new AWS.Endpoint(process.env.DO_ENDPOINT);
// console.log("configuration ", configuration);
diff --git a/apps/mongo/default-data/legadraGCva.w_menu.json b/apps/mongo/default-data/legadraGCva.w_menu.json
index 034bfb91e..1564de80e 100644
--- a/apps/mongo/default-data/legadraGCva.w_menu.json
+++ b/apps/mongo/default-data/legadraGCva.w_menu.json
@@ -1,4 +1,5 @@
-[{
+[
+ {
"_id": "H9vRfEYKhT",
"_created_at": {
"$date": "2023-09-04T14:04:00.669Z"
@@ -105,6 +106,14 @@
"pageType": "report",
"description": "",
"objectId": "zNqBHXHsYH"
+ },
+ {
+ "icon": "fa-solid fa-address-book",
+ "title": "Contactbook",
+ "target": "_self",
+ "pageType": "report",
+ "description": "",
+ "objectId": "5KhaPr482K"
}
]
},
@@ -237,6 +246,14 @@
"pageType": "report",
"description": "",
"objectId": "zNqBHXHsYH"
+ },
+ {
+ "icon": "fa-solid fa-address-book",
+ "title": "Contactbook",
+ "target": "_self",
+ "pageType": "report",
+ "description": "",
+ "objectId": "5KhaPr482K"
}
]
},
@@ -269,4 +286,5 @@
],
"menuTitle": "Admin Menu",
"menuType": "Side Menu"
- }]
\ No newline at end of file
+ }
+]
\ No newline at end of file
diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
index d26887d24..acfeca3e5 100644
--- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
+++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js
@@ -1,6 +1,6 @@
import React, { useState, useRef, useEffect } from "react";
import { themeColor } from "../utils/ThemeColor/backColor";
-import { PDFDocument, rgb } from "pdf-lib";
+import { PDFDocument } from "pdf-lib";
import "../css/signature.css";
import axios from "axios";
import ModalHeader from "react-bootstrap/esm/ModalHeader";
@@ -16,7 +16,9 @@ import {
contractDocument,
getBase64FromIMG,
getBase64FromUrl,
- urlValidator
+ urlValidator,
+ multiSignEmbed,
+ embedDocId
} from "../utils/Utils";
import Loader from "./component/loader";
import HandleError from "./component/HandleError";
@@ -319,29 +321,12 @@ function PdfRequestFiles() {
if (isDocId) {
pdfBase64 = await getBase64FromUrl(url);
} else {
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent =
- documentId && `OpenSign™ DocumentId: ${documentId}`;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
+ //embed document's object id to all pages in pdf document
+ await embedDocId(pdfDoc, documentId, allPages);
pdfBase64 = await pdfDoc.saveAsBase64({
useObjectStreams: false
});
}
-
for (let i = 0; i < pngUrl.length; i++) {
const imgUrlList = pngUrl[i].pos;
const pageNo = pngUrl[i].pageNumber;
@@ -381,112 +366,15 @@ function PdfRequestFiles() {
}
//else if signature is more than one then embed all sign with the use of pdf-lib
else if (pngUrl.length > 0 && pngUrl[0].pos.length > 0) {
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent =
- documentId && `OpenSign™ DocumentId: ${documentId} `;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
-
- for (let i = 0; i < pngUrl.length; i++) {
- const pageNo = pngUrl[i].pageNumber;
-
- const imgUrlList = pngUrl[i].pos;
- const pages = pdfDoc.getPages();
- const page = pages[pageNo - 1];
-
- const images = await Promise.all(
- imgUrlList.map(async (url) => {
- let signUrl = url.SignUrl;
- if (url.ImageType === "image/png") {
- //function for convert signature png base64 url to jpeg base64
- const newUrl = await convertPNGtoJPEG(signUrl);
- signUrl = newUrl;
- }
- const checkUrl = urlValidator(signUrl);
- if (checkUrl) {
- signUrl = signUrl + "?get";
- }
- const res = await fetch(signUrl);
- return res.arrayBuffer();
- })
- );
- images.forEach(async (imgData, id) => {
- let img = await pdfDoc.embedJpg(imgData);
- const imgHeight = imgUrlList[id].Height
- ? imgUrlList[id].Height
- : 60;
- const imgWidth = imgUrlList[id].Width
- ? imgUrlList[id].Width
- : 150;
- const isMobile = window.innerWidth < 767;
- const newWidth = window.innerWidth;
- const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
- const xPos = (pos) => {
- //checking both condition mobile and desktop view
- if (isMobile) {
- //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
- if (pos.isMobile) {
- const x = pos.xPosition * (pos.scale / scale);
- return x * scale + 50;
- } else {
- const x = pos.xPosition / scale;
- return x * scale;
- }
- } else {
- //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
- if (pos.isMobile) {
- const x = pos.xPosition * pos.scale + 50;
- return x;
- } else {
- return pos.xPosition;
- }
- }
- };
- const yPos = (pos) => {
- //checking both condition mobile and desktop view
- const y = pos.yPosition / scale;
- if (isMobile) {
- //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
- if (pos.isMobile) {
- const y = pos.yPosition * (pos.scale / scale);
- return page.getHeight() - y * scale - imgHeight;
- } else {
- return page.getHeight() - y * scale - imgHeight;
- }
- } else {
- //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
- if (pos.isMobile) {
- const y = pos.yPosition * pos.scale;
- return page.getHeight() - y - imgHeight;
- } else {
- return page.getHeight() - pos.yPosition - imgHeight;
- }
- }
- };
- page.drawImage(img, {
- x: xPos(imgUrlList[id]),
- y: yPos(imgUrlList[id]),
- width: imgWidth,
- height: imgHeight
- });
- });
- }
- const pdfBytes = await pdfDoc.saveAsBase64({
- useObjectStreams: false
- });
+ //embed document's object id to all pages in pdf document
+ await embedDocId(pdfDoc, documentId, allPages);
+ //embed multi signature in pdf
+ const pdfBytes = await multiSignEmbed(
+ pngUrl,
+ pdfDoc,
+ pdfOriginalWidth,
+ false
+ );
signPdfFun(pdfBytes, documentId, pngUrl);
}
diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
index 2460d6c36..d072f2a3d 100644
--- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
+++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js
@@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from "react";
-import { PDFDocument, rgb } from "pdf-lib";
+import { PDFDocument } from "pdf-lib";
import "../css/./signature.css";
import sign from "../assests/sign3.png";
import stamp from "../assests/stamp2.png";
@@ -18,7 +18,9 @@ import ModalHeader from "react-bootstrap/esm/ModalHeader";
import {
convertPNGtoJPEG,
contractDocument,
- getBase64FromIMG
+ getBase64FromIMG,
+ embedDocId,
+ multiSignEmbed
} from "../utils/Utils";
import { useParams } from "react-router-dom";
import Tour from "reactour";
@@ -30,7 +32,7 @@ import Header from "./component/header";
import RenderPdf from "./component/renderPdf";
import { contractUsers, contactBook, urlValidator } from "../utils/Utils";
import { modalAlign } from "../utils/Utils";
-import { $ } from "select-dom";
+
//For signYourself inProgress section signer can add sign and complete doc sign.
function SignYourSelf() {
const [pdfDetails, setPdfDetails] = useState([]);
@@ -422,24 +424,7 @@ function SignYourSelf() {
//checking if signature is only one then send image url in jpeg formate to server
if (xyPostion.length === 1 && xyPostion[0].pos.length === 1) {
//embed document's object id to all pages in pdf document
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent =
- documentId && `OpenSign™ DocumentId: ${documentId}`;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
+ await embedDocId(pdfDoc, documentId, allPages);
const pdfBase64 = await pdfDoc.saveAsBase64({
useObjectStreams: false
});
@@ -475,85 +460,15 @@ function SignYourSelf() {
}
//else if signature is more than one then embed all sign with the use of pdf-lib
else if (xyPostion.length > 0 && xyPostion[0].pos.length > 0) {
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent =
- documentId && `OpenSign™ DocumentId: ${documentId} `;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
- for (let i = 0; i < pngUrl.length; i++) {
- const pageNo = pngUrl[i].pageNumber;
-
- const imgUrlList = pngUrl[i].pos;
- const pages = pdfDoc.getPages();
- const page = pages[pageNo - 1];
-
- const images = await Promise.all(
- imgUrlList.map(async (url) => {
- let signUrl = url.SignUrl;
-
- if (url.ImageType === "image/png") {
- //function for convert signature png base64 url to jpeg base64
- const newUrl = await convertPNGtoJPEG(signUrl);
- signUrl = newUrl;
- }
- const checkUrl = urlValidator(signUrl);
- if (checkUrl) {
- signUrl = signUrl + "?get";
- }
- const res = await fetch(signUrl);
-
- return res.arrayBuffer();
- })
- );
- images.forEach(async (imgData, id) => {
- let img = await pdfDoc.embedJpg(imgData);
- const imgHeight = imgUrlList[id].Height
- ? imgUrlList[id].Height
- : 60;
- const imgWidth = imgUrlList[id].Width ? imgUrlList[id].Width : 150;
- const isMobile = window.innerWidth < 767;
- const newWidth = window.innerWidth;
- const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
-
- const posY = () => {
- if (isMobile) {
- if (id === 0) {
- return (
- page.getHeight() -
- imgUrlList[id].yPosition * scale -
- imgHeight
- );
- } else if (id > 0) {
- return page.getHeight() - imgUrlList[id].yPosition * scale;
- }
- } else {
- return page.getHeight() - imgUrlList[id].yPosition - imgHeight;
- }
- };
- page.drawImage(img, {
- x: isMobile
- ? imgUrlList[id].xPosition * scale + imgWidth / 2
- : imgUrlList[id].xPosition,
- y: posY(),
- width: imgWidth,
- height: imgHeight
- });
- });
- }
- const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
+ //embed document's object id to all pages in pdf document
+ await embedDocId(pdfDoc, documentId, allPages);
+ //embed multi signature in pdf
+ const pdfBytes = await multiSignEmbed(
+ pngUrl,
+ pdfDoc,
+ pdfOriginalWidth,
+ true
+ );
signPdfFun(pdfBytes, documentId);
}
setIsSignPad(false);
@@ -574,16 +489,16 @@ function SignYourSelf() {
let singleSign;
const isMobile = window.innerWidth < 767;
- const newWidth = window.innerWidth;
+ const newWidth = window.innerWidth - 32;
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
const imgWidth = xyPosData ? xyPosData.Width : 150;
if (xyPostion.length === 1 && xyPostion[0].pos.length === 1) {
const height = xyPosData.Height ? xyPosData.Height : 60;
const bottomY = xyPosData.isDrag
- ? xyPosData.yBottom * scale - height
+ ? xyPosData.yBottom * scale - height * scale
: xyPosData.firstYPos
- ? xyPosData.yBottom * scale - height + xyPosData.firstYPos
- : xyPosData.yBottom * scale - height;
+ ? xyPosData.yBottom * scale - height * scale + xyPosData.firstYPos
+ : xyPosData.yBottom * scale - height * scale;
singleSign = {
pdfFile: pdfBase64Url,
@@ -591,11 +506,11 @@ function SignYourSelf() {
sign: {
Base64: base64Url,
Left: isMobile
- ? xyPosData.xPosition * scale + imgWidth / 2
+ ? xyPosData.xPosition * scale + 43
: xyPosData.xPosition,
Bottom: bottomY,
- Width: xyPosData.Width ? xyPosData.Width : 150,
- Height: height,
+ Width: xyPosData.Width ? xyPosData.Width * scale : 150 * scale,
+ Height: height * scale,
Page: pageNo
}
};
diff --git a/microfrontends/SignDocuments/src/Component/component/emailComponent.js b/microfrontends/SignDocuments/src/Component/component/emailComponent.js
index 1158ff128..cb67fd0b3 100644
--- a/microfrontends/SignDocuments/src/Component/component/emailComponent.js
+++ b/microfrontends/SignDocuments/src/Component/component/emailComponent.js
@@ -274,8 +274,7 @@ function EmailComponent({
{data}
@@ -287,7 +286,8 @@ function EmailComponent({
src={close}
width={10}
height={10}
- style={{ fontWeight: "600", margin: "0 0 10px 2px" }}
+ style={{ fontWeight: "600", marginLeft: "7px" }}
+ className="emailChipClose"
/>
);
diff --git a/microfrontends/SignDocuments/src/Component/component/renderPdf.js b/microfrontends/SignDocuments/src/Component/component/renderPdf.js
index 58e3670cd..abe0d34fe 100644
--- a/microfrontends/SignDocuments/src/Component/component/renderPdf.js
+++ b/microfrontends/SignDocuments/src/Component/component/renderPdf.js
@@ -42,8 +42,8 @@ function RenderPdf({
const isMobile = window.innerWidth < 767;
const newWidth = window.innerWidth;
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
- //check isGuestSigner is present in local if yes than handle login flow header in mobile view
- const isGuestSigner = localStorage.getItem("isGuestSigner");
+ //check isGuestSigner is present in local if yes than handle login flow header in mobile view
+ const isGuestSigner = localStorage.getItem("isGuestSigner");
// handle signature block width and height according to screen
const posWidth = (pos) => {
let width;
@@ -75,7 +75,6 @@ function RenderPdf({
return width;
}
};
-
//function for render placeholder block over pdf document
const checkSignedSignes = (data) => {
@@ -434,279 +433,144 @@ function RenderPdf({
);
})
: pdfRequest
- ? signerPos.map((data, key) => {
- return (
-
- {checkSignedSignes(data)}
-
- );
- })
- : placeholder
- ? signerPos.map((data, ind) => {
- return (
-
- {data.placeHolder.map((placeData, index) => {
- return (
-
- {placeData.pageNumber === pageNumber &&
- placeData.pos.map((pos) => {
- return (
-
- handleTabDrag(pos.key, data.signerObjId)
- }
- size={{
- width: pos.Width ? pos.Width : 150,
- height: pos.Height ? pos.Height : 60
- }}
- lockAspectRatio={
- pos.Width ? pos.Width / pos.Height : 2.5
- }
- resizeHandleStyles={{
- bottom: { display: "none" },
- right: { display: "none" },
- bottomRight: { display: "block" }
- }}
- onDragStop={(event, dragElement) =>
- handleStop(
- event,
- dragElement,
- data.signerObjId,
- pos.key
- )
- }
- default={{
- x: pos.xPosition,
- y: pos.yPosition
- }}
- onResize={(
- e,
- direction,
- ref,
- delta,
- position
- ) => {
- handleImageResize(
- ref,
- pos.key,
- data.signerObjId,
- position
- );
- }}
- >
- {
- e.stopPropagation();
- handleDeleteSign(
- pos.key,
- data.signerObjId
- );
- }}
- style={{
- position: "absolute",
- right: 0,
- display: "inline-block",
- background: themeColor(),
- cursor: "pointer",
- padding: "0px 10px",
- zIndex: 10
- }}
- >
- x
-
- {
+ return (
+
+ {checkSignedSignes(data)}
+
+ );
+ })
+ : placeholder
+ ? signerPos.map((data, ind) => {
+ return (
+
+ {data.placeHolder.map((placeData, index) => {
+ return (
+
+ {placeData.pageNumber === pageNumber &&
+ placeData.pos.map((pos) => {
+ return (
+
+ handleTabDrag(
+ pos.key,
+ data.signerObjId
+ )
+ }
+ size={{
+ width: pos.Width ? pos.Width : 150,
+ height: pos.Height ? pos.Height : 60
+ }}
+ lockAspectRatio={
+ pos.Width
+ ? pos.Width / pos.Height
+ : 2.5
+ }
+ resizeHandleStyles={{
+ bottom: { display: "none" },
+ right: { display: "none" },
+ bottomRight: { display: "block" }
+ }}
+ onDragStop={(event, dragElement) =>
+ handleStop(
+ event,
+ dragElement,
+ data.signerObjId,
+ pos.key
+ )
+ }
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
+ }}
+ onResize={(
+ e,
+ direction,
+ ref,
+ delta,
+ position
+ ) => {
+ handleImageResize(
+ ref,
+ pos.key,
+ data.signerObjId,
+ position
+ );
+ }}
+ >
+ {
+ e.stopPropagation();
+ handleDeleteSign(
+ pos.key,
+ data.signerObjId
+ );
+ }}
+ style={{
+ position: "absolute",
+ right: 0,
+ display: "inline-block",
+ background: themeColor(),
+ cursor: "pointer",
+ padding: "0px 10px",
+ zIndex: 10
+ }}
+ >
+ x
+
+
- {pos.isStamp ? "stamp" : "signature"}
-
-
- );
- })}
-
- );
- })}
-
- );
- })
- : xyPostion.map((data, ind) => {
- return (
-
- {data.pageNumber === pageNumber &&
- data.pos.map((pos) => {
- return pos && pos.SignUrl ? (
- handleTabDrag(pos.key)}
- onDragStop={handleStop}
- onResize={(
- e,
- direction,
- ref,
- delta,
- position
- ) => {
- handleImageResize(
- ref,
- pos.key,
- direction,
- position
- );
- }}
- >
- {" "}
- {
- if (!isDragging) {
- setTimeout(() => {
- e.stopPropagation();
- setIsSignPad(true);
- setSignKey(pos.key);
- setIsStamp(pos.isStamp);
- }, 500);
+ marginTop: "0px"
+ }}
+ >
+ {pos.isStamp ? "stamp" : "signature"}
+
+
+ );
+ })}
+
+ );
+ })}
+
+ );
+ })
+ : xyPostion.map((data, ind) => {
+ return (
+
+ {data.pageNumber === pageNumber &&
+ data.pos.map((pos) => {
+ return pos && pos.SignUrl ? (
+
- {
- e.stopPropagation();
- handleDeleteSign(pos.key);
- setIsStamp(false);
- }}
- style={{
- position: "absolute",
- right: 0,
- display: "inline-block",
- background: themeColor(),
- cursor: "pointer",
- padding: "0px 10px"
- }}
- >
- x
-
-
-
{
- setSignKey(pos.key);
- console.log("Drag 2");
- setIsSignPad(true);
- setIsStamp(pos.isStamp);
- }}
- src={pos.SignUrl}
- style={{
- width: "100%",
- height: "100%",
- objectFit: "contain"
- }}
- />
-
-
-
- ) : (
- <>
- {
- handleTabDrag(pos.key, e);
- }}
- onDragStop={handleStop}
- size={{
- width: pos.Width ? pos.Width : 150,
- height: pos.Height ? pos.Height : 60
- }}
- default={{
- x: pos.xPosition,
- y: pos.yPosition
- }}
- >
- {
- if (!isDragging) {
- setTimeout(() => {
- setIsSignPad(true);
- setSignKey(pos.key);
- setIsStamp(pos.isStamp);
- }, 500);
- }
- }}
- className="dragElm"
+ key={pos.key}
style={{
padding: "0px",
cursor: "all-scroll",
- zIndex: 20,
+ zIndex: 1,
position: "absolute",
borderStyle: "dashed",
width: "150px",
@@ -716,50 +580,190 @@ function RenderPdf({
textAlign: "center",
justifyContent: "center",
borderWidth: "0.2px",
- overflow: "hidden"
+ overflow: "hidden",
+ userSelect: "none"
+ }}
+ size={{
+ width: pos.Width ? pos.Width : 151,
+ height: pos.Height ? pos.Height : 61
+ }}
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
+ }}
+ onDrag={() => handleTabDrag(pos.key)}
+ onDragStop={handleStop}
+ onResize={(
+ e,
+ direction,
+ ref,
+ delta,
+ position
+ ) => {
+ handleImageResize(
+ ref,
+ pos.key,
+ direction,
+ position
+ );
}}
>
+ {" "}
{
- e.stopPropagation();
- e.preventDefault();
-
- handleDeleteSign(pos.key);
- setIsStamp(false);
- }}
- onClick={(e) => {
- e.stopPropagation(); // Prevent further event propagation
+ onTouchEnd={(e) => {
+ if (!isDragging) {
+ setTimeout(() => {
+ e.stopPropagation();
+ setIsSignPad(true);
+ setSignKey(pos.key);
+ setIsStamp(pos.isStamp);
+ }, 500);
+ }
}}
+ >
+
{
+ e.stopPropagation();
+ handleDeleteSign(pos.key);
+ setIsStamp(false);
+ }}
+ style={{
+ position: "absolute",
+ right: 0,
+ display: "inline-block",
+ background: themeColor(),
+ cursor: "pointer",
+ padding: "0px 10px"
+ }}
+ >
+ x
+
+
+
{
+ setSignKey(pos.key);
+ console.log("Drag 2");
+ setIsSignPad(true);
+ setIsStamp(pos.isStamp);
+ }}
+ src={pos.SignUrl}
+ style={{
+ width: "100%",
+ height: "100%",
+ objectFit: "contain"
+ }}
+ />
+
+
+
+ ) : (
+ <>
+
- x
-
- {
+ handleTabDrag(pos.key, e);
+ }}
+ onDragStop={handleStop}
+ size={{
+ width: pos.Width ? pos.Width : 150,
+ height: pos.Height ? pos.Height : 60
+ }}
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
}}
>
- {pos.isStamp ? "stamp" : "signature"}
-
-
-
- >
- );
- })}
-
- );
- }))}
+ {
+ if (!isDragging) {
+ setTimeout(() => {
+ setIsSignPad(true);
+ setSignKey(pos.key);
+ setIsStamp(pos.isStamp);
+ }, 500);
+ }
+ }}
+ className="dragElm"
+ style={{
+ padding: "0px",
+ cursor: "all-scroll",
+ zIndex: 20,
+ position: "absolute",
+ borderStyle: "dashed",
+ width: "150px",
+ height: "60px",
+ borderColor: themeColor(),
+ background: "#daebe0",
+ textAlign: "center",
+ justifyContent: "center",
+ borderWidth: "0.2px",
+ overflow: "hidden"
+ }}
+ >
+
{
+ e.stopPropagation();
+ e.preventDefault();
+
+ handleDeleteSign(pos.key);
+ setIsStamp(false);
+ }}
+ onClick={(e) => {
+ e.stopPropagation(); // Prevent further event propagation
+ }}
+ style={{
+ position: "absolute",
+ right: 0,
+ display: "inline-block",
+ background: themeColor(),
+ cursor: "pointer",
+ padding: "0px 10px"
+ }}
+ >
+ x
+
+
+ {pos.isStamp ? "stamp" : "signature"}
+
+
+
+ >
+ );
+ })}
+
+ );
+ }))}
{/* this component for render pdf document is in middle of the component */}
{Array.from(new Array(numPages), (el, index) => (
{
@@ -980,89 +984,289 @@ function RenderPdf({
);
})
: pdfRequest
- ? signerPos.map((data, key) => {
- return (
-
- {checkSignedSignes(data)}
-
- );
- })
- : placeholder
- ? signerPos.map((data, ind) => {
- return (
-
- {data.placeHolder.map((placeData, index) => {
- return (
-
- {placeData.pageNumber === pageNumber &&
- placeData.pos.map((pos) => {
- return (
- {
+ return (
+
+ {checkSignedSignes(data)}
+
+ );
+ })
+ : placeholder
+ ? signerPos.map((data, ind) => {
+ return (
+
+ {data.placeHolder.map((placeData, index) => {
+ return (
+
+ {placeData.pageNumber === pageNumber &&
+ placeData.pos.map((pos) => {
+ return (
+
+ handleTabDrag(
+ pos.key,
+ data.signerObjId
+ )
+ }
+ size={{
+ width: pos.Width ? pos.Width : 150,
+ height: pos.Height ? pos.Height : 60
+ }}
+ lockAspectRatio={
+ pos.Width
+ ? pos.Width / pos.Height
+ : 2.5
+ }
+ resizeHandleStyles={{
+ bottom: { display: "none" },
+ right: { display: "none" },
+ bottomRight: { display: "block" }
+ }}
+ onDragStop={(event, dragElement) =>
+ handleStop(
+ event,
+ dragElement,
+ data.signerObjId,
+ pos.key
+ )
+ }
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
+ }}
+ onResize={(
+ e,
+ direction,
+ ref,
+ delta,
+ position
+ ) => {
+ handleImageResize(
+ ref,
+ pos.key,
+ data.signerObjId,
+ position
+ );
+ }}
+ >
+ {
+ e.stopPropagation();
+ handleDeleteSign(
+ pos.key,
+ data.signerObjId
+ );
+ }}
+ style={{
+ position: "absolute",
+ right: 0,
+ display: "inline-block",
+ background: themeColor(),
+ cursor: "pointer",
+ padding: "0px 10px",
+ zIndex: 10
+ }}
+ >
+ x
+
+
+ {pos.isStamp
+ ? "stamp"
+ : "signature"}
+
+
+ );
+ })}
+
+ );
+ })}
+
+ );
+ })
+ : xyPostion.map((data, ind) => {
+ return (
+
+ {data.pageNumber === pageNumber &&
+ data.pos.map((pos) => {
+ return pos && pos.SignUrl ? (
+ handleTabDrag(pos.key)}
+ size={{
+ width: pos.Width ? pos.Width : 150,
+ height: pos.Height ? pos.Height : 60
+ }}
+ onDragStop={handleStop}
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
+ }}
+ onResize={(
+ e,
+ direction,
+ ref,
+ delta,
+ position
+ ) => {
+ handleImageResize(
+ ref,
+ pos.key,
+ direction,
+ position
+ );
+ }}
+ onClick={() => {
+ if (!isDragging) {
+ setIsSignPad(true);
+ setSignKey(pos.key);
+ setIsStamp(pos.isStamp);
+ }
+ }}
+ >
+ {
+ e.stopPropagation();
+ handleDeleteSign(pos.key);
+ setIsStamp(false);
+ }}
+ style={{
+ position: "absolute",
+ right: 0,
+ display: "inline-block",
+ background: themeColor(),
+ cursor: "pointer",
+ padding: "0px 10px"
+ }}
+ >
+ x
+
+
+
{
+ setSignKey(pos.key);
+ setIsSignPad(true);
+ setIsStamp(pos.isStamp);
+ }}
+ src={pos.SignUrl}
+ style={{
+ width: "100%",
+ height: "100%",
+ objectFit: "contain"
+ }}
+ />
+
+
+ ) : (
+ handleTabDrag(pos.key, e)}
+ size={{
+ width: pos.Width ? pos.Width : 150,
+ height: pos.Height ? pos.Height : 60
+ }}
+ onDragStop={handleStop}
+ default={{
+ x: pos.xPosition,
+ y: pos.yPosition
+ }}
+ >
+ {
+ if (!isDragging) {
+ e.stopPropagation();
+ setIsSignPad(true);
+ setSignKey(pos.key);
+ setIsStamp(pos.isStamp);
+ }
+ }}
style={{
- padding: "0px",
cursor: "all-scroll",
- zIndex: 1,
+ zIndex: 10,
position: "absolute",
borderStyle: "dashed",
- width: "200px",
- height: "30px",
+ width: "150px",
+ height: "60px",
borderColor: themeColor(),
- background: data.blockColor,
+ background: "#daebe0",
textAlign: "center",
justifyContent: "center",
+ alignItems: "center",
borderWidth: "0.2px"
}}
- onDrag={() =>
- handleTabDrag(pos.key, data.signerObjId)
- }
- size={{
- width: pos.Width ? pos.Width : 150,
- height: pos.Height ? pos.Height : 60
- }}
- lockAspectRatio={
- pos.Width ? pos.Width / pos.Height : 2.5
- }
- resizeHandleStyles={{
- bottom: { display: "none" },
- right: { display: "none" },
- bottomRight: { display: "block" }
- }}
- onDragStop={(event, dragElement) =>
- handleStop(
- event,
- dragElement,
- data.signerObjId,
- pos.key
- )
- }
- default={{
- x: pos.xPosition,
- y: pos.yPosition
- }}
- onResize={(
- e,
- direction,
- ref,
- delta,
- position
- ) => {
- handleImageResize(
- ref,
- pos.key,
- data.signerObjId,
- position
- );
- }}
>
{
e.stopPropagation();
- handleDeleteSign(
- pos.key,
- data.signerObjId
- );
+ handleDeleteSign(pos.key);
+ setIsStamp(false);
}}
style={{
position: "absolute",
@@ -1070,8 +1274,7 @@ function RenderPdf({
display: "inline-block",
background: themeColor(),
cursor: "pointer",
- padding: "0px 10px",
- zIndex: 10
+ padding: "0px 10px"
}}
>
x
@@ -1079,212 +1282,20 @@ function RenderPdf({
{pos.isStamp ? "stamp" : "signature"}
-
- );
- })}
-
- );
- })}
-
- );
- })
- : xyPostion.map((data, ind) => {
- return (
-
- {data.pageNumber === pageNumber &&
- data.pos.map((pos) => {
- return pos && pos.SignUrl ? (
- handleTabDrag(pos.key)}
- size={{
- width: pos.Width ? pos.Width : 150,
- height: pos.Height ? pos.Height : 60
- }}
- onDragStop={handleStop}
- default={{
- x: pos.xPosition,
- y: pos.yPosition
- }}
- onResize={(
- e,
- direction,
- ref,
- delta,
- position
- ) => {
- handleImageResize(
- ref,
- pos.key,
- direction,
- position
- );
- }}
- onClick={() => {
- if (!isDragging) {
- setIsSignPad(true);
- setSignKey(pos.key);
- setIsStamp(pos.isStamp);
- }
- }}
- >
- {
- e.stopPropagation();
- handleDeleteSign(pos.key);
- setIsStamp(false);
- }}
- style={{
- position: "absolute",
- right: 0,
- display: "inline-block",
- background: themeColor(),
- cursor: "pointer",
- padding: "0px 10px"
- }}
- >
- x
-
-
-
{
- setSignKey(pos.key);
- setIsSignPad(true);
- setIsStamp(pos.isStamp);
- }}
- src={pos.SignUrl}
- style={{
- width: "100%",
- height: "100%",
- objectFit: "contain"
- }}
- />
-
-
- ) : (
- handleTabDrag(pos.key, e)}
- size={{
- width: pos.Width ? pos.Width : 150,
- height: pos.Height ? pos.Height : 60
- }}
- onDragStop={handleStop}
- default={{
- x: pos.xPosition,
- y: pos.yPosition
- }}
- >
- {
- if (!isDragging) {
- e.stopPropagation();
- setIsSignPad(true);
- setSignKey(pos.key);
- setIsStamp(pos.isStamp);
- }
- }}
- style={{
- cursor: "all-scroll",
- zIndex: 10,
- position: "absolute",
- borderStyle: "dashed",
- width: "150px",
- height: "60px",
- borderColor: themeColor(),
- background: "#daebe0",
- textAlign: "center",
- justifyContent: "center",
- alignItems: "center",
- borderWidth: "0.2px"
- }}
- >
-
{
- e.stopPropagation();
- handleDeleteSign(pos.key);
- setIsStamp(false);
- }}
- style={{
- position: "absolute",
- right: 0,
- display: "inline-block",
- background: themeColor(),
- cursor: "pointer",
- padding: "0px 10px"
- }}
- >
- x
-
-
- {pos.isStamp ? "stamp" : "signature"}
-
-
-
- );
- })}
-
- );
- }))}
+
+
+ );
+ })}
+
+ );
+ }))}
{/* this component for render pdf document is in middle of the component */}
{Array.from(new Array(numPages), (el, index) => (
@@ -1326,4 +1337,4 @@ function RenderPdf({
);
}
-export default RenderPdf;
\ No newline at end of file
+export default RenderPdf;
diff --git a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
index 801a30a54..2d73241b9 100644
--- a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
+++ b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js
@@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from "react";
-import { PDFDocument, rgb } from "pdf-lib";
+import { PDFDocument } from "pdf-lib";
import "../css/./signature.css";
import axios from "axios";
import Modal from "react-bootstrap/Modal";
@@ -19,7 +19,9 @@ import {
contractUsers,
contactBook,
contractDocument,
- urlValidator
+ urlValidator,
+ multiSignEmbed,
+ embedDocId
} from "../utils/Utils";
import Tour from "reactour";
import Signedby from "./component/signedby";
@@ -424,23 +426,8 @@ function EmbedPdfImage() {
if (isDocId) {
pdfBase64 = await getBase64FromUrl(url);
} else {
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent = docId && `OpenSign™ DocumentId: ${docId} `;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
+ //embed document's object id to all pages in pdf document
+ await embedDocId(pdfDoc, docId, allPages);
pdfBase64 = await pdfDoc.saveAsBase64({ useObjectStreams: false });
}
for (let i = 0; i < xyPostion.length; i++) {
@@ -475,115 +462,18 @@ function EmbedPdfImage() {
}
//else if signature is more than one then embed all sign with the use of pdf-lib
else if (xyPostion.length > 0 && xyPostion[0].pos.length > 0) {
- for (let i = 0; i < allPages; i++) {
- const font = await pdfDoc.embedFont("Helvetica");
-
- const fontSize = 10;
- const textContent = docId && `OpenSign™ DocumentId: ${docId} `;
-
- const pages = pdfDoc.getPages();
- const page = pages[i];
-
- page.drawText(textContent, {
- x: 10,
- y: page.getHeight() - 10,
- size: fontSize,
- font,
- color: rgb(0.5, 0.5, 0.5)
- });
- }
- for (let i = 0; i < pngUrl.length; i++) {
- const pageNo = pngUrl[i].pageNumber;
-
- const imgUrlList = pngUrl[i].pos;
- const pages = pdfDoc.getPages();
- const page = pages[pageNo - 1];
-
- const images = await Promise.all(
- imgUrlList.map(async (url) => {
- let signUrl = url.SignUrl;
- if (url.ImageType === "image/png") {
- //function for convert signature png base64 url to jpeg base64
- const newUrl = await convertPNGtoJPEG(signUrl);
- signUrl = newUrl;
- }
- const checkUrl = urlValidator(signUrl);
- if (checkUrl) {
- signUrl = signUrl + "?get";
- }
- const res = await fetch(signUrl);
-
- return res.arrayBuffer();
- })
- );
- images.forEach(async (imgData, id) => {
- let img = await pdfDoc.embedJpg(imgData);
-
- const imgHeight = imgUrlList[id].Height
- ? imgUrlList[id].Height
- : 60;
- const imgWidth = imgUrlList[id].Width ? imgUrlList[id].Width : 150;
- const isMobile = window.innerWidth < 767;
- const newWidth = window.innerWidth;
- const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
- const xPos = (pos) => {
- //checking both condition mobile and desktop view
- if (isMobile) {
- //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
- if (pos.isMobile) {
- const x = pos.xPosition * (pos.scale / scale);
- return x * scale + 50;
- } else {
- const x = pos.xPosition / scale;
- return x * scale;
- }
- } else {
- //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
- if (pos.isMobile) {
- const x = pos.xPosition * pos.scale + 50;
- return x;
- } else {
- return pos.xPosition;
- }
- }
- };
- const yPos = (pos) => {
- //checking both condition mobile and desktop view
-
- if (isMobile) {
- //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
- if (pos.isMobile) {
- const y = pos.yPosition * (pos.scale / scale);
- return page.getHeight() - y * scale - imgHeight;
- } else {
- const y = pos.yPosition / scale;
- return page.getHeight() - y * scale - imgHeight;
- }
- } else {
- //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
- if (pos.isMobile) {
- const y = pos.yPosition * pos.scale;
- return page.getHeight() - y - imgHeight;
- } else {
- return page.getHeight() - pos.yPosition - imgHeight;
- }
- }
- };
-
- page.drawImage(img, {
- x: xPos(imgUrlList[id]),
- y: yPos(imgUrlList[id]),
- width: imgWidth,
- height: imgHeight
- });
- });
- }
- const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
+ //embed document's object id to all pages in pdf document
+ await embedDocId(pdfDoc, docId, allPages);
+ //embed multi signature in pdf
+ const pdfBytes = await multiSignEmbed(
+ pngUrl,
+ pdfDoc,
+ pdfOriginalWidth,
+ false
+ );
signPdfFun(pdfBytes, docId);
}
-
setIsSignPad(false);
-
setXyPostion([]);
}
}
diff --git a/microfrontends/SignDocuments/src/css/signature.css b/microfrontends/SignDocuments/src/css/signature.css
index cda96f958..fb97f992e 100644
--- a/microfrontends/SignDocuments/src/css/signature.css
+++ b/microfrontends/SignDocuments/src/css/signature.css
@@ -80,6 +80,10 @@
padding: 5px 10px;
}
+.emailChipClose:hover {
+ cursor: pointer;
+}
+
.addEmailInput {
padding: 10px;
border-radius: 4px;
@@ -639,6 +643,7 @@ option {
.stickyfooter {
position: fixed;
+ z-index: 32 !important;
bottom: 0px;
right: 0rem;
}
@@ -785,4 +790,4 @@ option {
.signature-backdrop.fade.in {
opacity: 0.5;
-}
\ No newline at end of file
+}
diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js
index a78fc3e94..015f97f7f 100644
--- a/microfrontends/SignDocuments/src/utils/Utils.js
+++ b/microfrontends/SignDocuments/src/utils/Utils.js
@@ -1,6 +1,6 @@
import axios from "axios";
-import { $ } from 'select-dom';
-
+import { $ } from "select-dom";
+import { rgb } from "pdf-lib";
export async function getBase64FromUrl(url) {
const data = await fetch(url);
const blob = await data.blob();
@@ -327,18 +327,155 @@ export const contactBook = async (objectId) => {
export function urlValidator(url) {
try {
const newUrl = new URL(url);
- return newUrl.protocol === 'http:' || newUrl.protocol === 'https:';
+ return newUrl.protocol === "http:" || newUrl.protocol === "https:";
} catch (err) {
return false;
}
}
export function modalAlign() {
- let modalDialog = $('.modal-dialog').getBoundingClientRect();
- let mobileHead = $('.mobileHead').getBoundingClientRect()
- let modal = $('.modal-dialog');
+ let modalDialog = $(".modal-dialog").getBoundingClientRect();
+ let mobileHead = $(".mobileHead").getBoundingClientRect();
+ let modal = $(".modal-dialog");
if (modalDialog.left < mobileHead.left) {
let leftOffset = mobileHead.left - modalDialog.left;
- modal.style.left = leftOffset + 'px';
- modal.style.top = (window.innerHeight/3) + 'px';
+ modal.style.left = leftOffset + "px";
+ modal.style.top = window.innerHeight / 3 + "px";
+ }
+}
+
+//function for embed multiple signature using pdf-lib
+export const multiSignEmbed = async (
+ pngUrl,
+ pdfDoc,
+ pdfOriginalWidth,
+ signyourself
+) => {
+ for (let i = 0; i < pngUrl.length; i++) {
+ const pageNo = pngUrl[i].pageNumber;
+ const imgUrlList = pngUrl[i].pos;
+ const pages = pdfDoc.getPages();
+ const page = pages[pageNo - 1];
+ const images = await Promise.all(
+ imgUrlList.map(async (url) => {
+ let signUrl = url.SignUrl;
+ if (url.ImageType === "image/png") {
+ //function for convert signature png base64 url to jpeg base64
+ const newUrl = await convertPNGtoJPEG(signUrl);
+ signUrl = newUrl;
+ }
+ const checkUrl = urlValidator(signUrl);
+ if (checkUrl) {
+ signUrl = signUrl + "?get";
+ }
+ const res = await fetch(signUrl);
+ return res.arrayBuffer();
+ })
+ );
+ images.forEach(async (imgData, id) => {
+ let img;
+ if (
+ (imgUrlList[id].ImageType &&
+ imgUrlList[id].ImageType === "image/png") ||
+ imgUrlList[id].ImageType === "image/jpeg"
+ ) {
+ img = await pdfDoc.embedJpg(imgData);
+ } else {
+ img = await pdfDoc.embedPng(imgData);
+ }
+ const imgHeight = imgUrlList[id].Height ? imgUrlList[id].Height : 60;
+ const imgWidth = imgUrlList[id].Width ? imgUrlList[id].Width : 150;
+ const isMobile = window.innerWidth < 767;
+ const newWidth = window.innerWidth - 32;
+ const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
+ const xPos = (pos) => {
+ if (signyourself) {
+ if (isMobile) {
+ return imgUrlList[id].xPosition * scale + 43;
+ } else {
+ return imgUrlList[id].xPosition;
+ }
+ } else {
+ //checking both condition mobile and desktop view
+ if (isMobile) {
+ //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
+ if (pos.isMobile) {
+ const x = pos.xPosition * (pos.scale / scale);
+ return x * scale + 50;
+ } else {
+ const x = pos.xPosition / scale;
+ return x * scale;
+ }
+ } else {
+ //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
+ if (pos.isMobile) {
+ const x = pos.xPosition * pos.scale + 50;
+ return x;
+ } else {
+ return pos.xPosition;
+ }
+ }
+ }
+ };
+
+ const yPos = (pos) => {
+ if (signyourself) {
+ if (isMobile) {
+ return (
+ page.getHeight() -
+ imgUrlList[id].yPosition * scale -
+ imgHeight * scale
+ );
+ } else {
+ return page.getHeight() - imgUrlList[id].yPosition - imgHeight;
+ }
+ } else {
+ //checking both condition mobile and desktop view
+ const y = pos.yPosition / scale;
+ if (isMobile) {
+ //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
+ if (pos.isMobile) {
+ const y = pos.yPosition * (pos.scale / scale);
+ return page.getHeight() - y * scale - imgHeight;
+ } else {
+ return page.getHeight() - y * scale - imgHeight;
+ }
+ } else {
+ //else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
+ if (pos.isMobile) {
+ const y = pos.yPosition * pos.scale;
+ return page.getHeight() - y - imgHeight;
+ } else {
+ return page.getHeight() - pos.yPosition - imgHeight;
+ }
+ }
+ }
+ };
+
+ page.drawImage(img, {
+ x: xPos(imgUrlList[id]),
+ y: yPos(imgUrlList[id]),
+ width: signyourself ? imgWidth * scale : imgWidth,
+ height: signyourself ? imgHeight * scale : imgHeight
+ });
+ });
+ }
+ const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
+ return pdfBytes;
+};
+//function for embed document id
+export const embedDocId = async (pdfDoc, documentId, allPages) => {
+ for (let i = 0; i < allPages; i++) {
+ const font = await pdfDoc.embedFont("Helvetica");
+ const fontSize = 10;
+ const textContent = documentId && `OpenSign™ DocumentId: ${documentId} `;
+ const pages = pdfDoc.getPages();
+ const page = pages[i];
+ page.drawText(textContent, {
+ x: 10,
+ y: page.getHeight() - 10,
+ size: fontSize,
+ font,
+ color: rgb(0.5, 0.5, 0.5)
+ });
}
};