diff --git a/apps/OpenSign/package-lock.json b/apps/OpenSign/package-lock.json index 311171281..4cc4ec3d6 100644 --- a/apps/OpenSign/package-lock.json +++ b/apps/OpenSign/package-lock.json @@ -43,6 +43,7 @@ "react-select": "^5.8.0", "react-signature-canvas": "^1.0.6", "react-tooltip": "^5.26.3", + "react-web-share": "^2.0.2", "reactour": "^1.19.2", "redux": "^5.0.1", "redux-thunk": "^3.1.0", @@ -20225,6 +20226,15 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-web-share": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/react-web-share/-/react-web-share-2.0.2.tgz", + "integrity": "sha512-bGm1TJc6xtC0MhAnYFsrzT4En7l2oAdLTgCK7nk7b4xGTg3L5gOldiPrmYQ8a/dEXNydgekvOj/tfjduIlIRVA==", + "peerDependencies": { + "react": "^16 || ^17 || ^18", + "react-dom": "^16 || ^17 || ^18" + } + }, "node_modules/reactour": { "version": "1.19.2", "resolved": "https://registry.npmjs.org/reactour/-/reactour-1.19.2.tgz", diff --git a/apps/OpenSign/package.json b/apps/OpenSign/package.json index 801361767..d7a59becc 100644 --- a/apps/OpenSign/package.json +++ b/apps/OpenSign/package.json @@ -38,6 +38,7 @@ "react-select": "^5.8.0", "react-signature-canvas": "^1.0.6", "react-tooltip": "^5.26.3", + "react-web-share": "^2.0.2", "reactour": "^1.19.2", "redux": "^5.0.1", "redux-thunk": "^3.1.0", diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js index e8bea0151..4d32a960e 100644 --- a/apps/OpenSign/src/constant/Utils.js +++ b/apps/OpenSign/src/constant/Utils.js @@ -1862,3 +1862,18 @@ export function replaceMailVaribles(subject, body, variables) { }; return result; } + +export const copytoData = (text) => { + // navigator.clipboard.writeText(text); + if (navigator.clipboard) { + navigator.clipboard.writeText(text); + } else { + // Fallback for browsers that don't support navigator.clipboard + const textArea = document.createElement("textarea"); + textArea.value = text; + document.body.appendChild(textArea); + textArea.select(); + document.execCommand("copy"); + document.body.removeChild(textArea); + } +}; diff --git a/apps/OpenSign/src/pages/GenerateToken.js b/apps/OpenSign/src/pages/GenerateToken.js index b5cb2b481..4ffcc2245 100644 --- a/apps/OpenSign/src/pages/GenerateToken.js +++ b/apps/OpenSign/src/pages/GenerateToken.js @@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom"; import Alert from "../primitives/Alert"; import ModalUi from "../primitives/ModalUi"; import { isEnableSubscription, rejectBtn, submitBtn } from "../constant/const"; -import { checkIsSubscribed, openInNewTab } from "../constant/Utils"; +import { checkIsSubscribed, copytoData, openInNewTab } from "../constant/Utils"; import PremiumAlertHeader from "../primitives/PremiumAlertHeader"; import Tooltip from "../primitives/Tooltip"; @@ -92,7 +92,7 @@ function GenerateToken() { }; const copytoclipboard = (text) => { - navigator.clipboard.writeText(text); + copytoData(text); setCopied(true); setTimeout(() => { setCopied(false); diff --git a/apps/OpenSign/src/pages/Login.js b/apps/OpenSign/src/pages/Login.js index f192e34c5..9a7501545 100644 --- a/apps/OpenSign/src/pages/Login.js +++ b/apps/OpenSign/src/pages/Login.js @@ -44,7 +44,7 @@ function Login() { Destination: "" }); const [isModal, setIsModal] = useState(false); - const [image, setImage] = useState(appInfo?.applogo); + const [image, setImage] = useState(); useEffect(() => { if (localStorage.getItem("accesstoken")) { @@ -65,6 +65,8 @@ function Login() { } else { setImage(appInfo?.applogo || undefined); } + } else { + setImage(appInfo?.applogo || undefined); } }; const handleChange = (event) => { diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index bc64c7766..30598b1c3 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -385,354 +385,351 @@ function PdfRequestFiles() { }); }; - const checkSendInOrder = () => { - if (sendInOrder) { - const index = pdfDetails?.[0].Signers.findIndex( - (x) => x.Email === jsonSender.email - ); - const newIndex = index - 1; - if (newIndex !== -1) { - const user = pdfDetails?.[0].Signers[newIndex]; - const isPrevUserSigned = - pdfDetails?.[0].AuditTrail && - pdfDetails?.[0].AuditTrail.some( - (x) => - x.UserPtr.objectId === user.objectId && x.Activity === "Signed" - ); - if (isPrevUserSigned) { - return true; - } else { - return false; - } - } else { - return true; - } - } else { - return true; - } - }; + // const checkSendInOrder = () => { + // if (sendInOrder) { + // const index = pdfDetails?.[0].Signers.findIndex( + // (x) => x.Email === jsonSender.email + // ); + // const newIndex = index - 1; + // if (newIndex !== -1) { + // const user = pdfDetails?.[0].Signers[newIndex]; + // const isPrevUserSigned = + // pdfDetails?.[0].AuditTrail && + // pdfDetails?.[0].AuditTrail.some( + // (x) => + // x.UserPtr.objectId === user.objectId && x.Activity === "Signed" + // ); + // if (isPrevUserSigned) { + // return true; + // } else { + // return false; + // } + // } else { + // return true; + // } + // } else { + // return true; + // } + // }; //function for embed signature or image url in pdf async function embedWidgetsData() { - const validateSigning = checkSendInOrder(); - if (validateSigning) { - const checkUser = signerPos.filter( - (data) => data.signerObjId === signerObjectId - ); - if (checkUser && checkUser.length > 0) { - let checkboxExist, - requiredRadio, - showAlert = false, - widgetKey, - radioExist, - requiredCheckbox; + // const validateSigning = checkSendInOrder(); + // if (validateSigning) { + const checkUser = signerPos.filter( + (data) => data.signerObjId === signerObjectId + ); + if (checkUser && checkUser.length > 0) { + let checkboxExist, + requiredRadio, + showAlert = false, + widgetKey, + radioExist, + requiredCheckbox; - for (let i = 0; i < checkUser[0].placeHolder.length; i++) { - for (let j = 0; j < checkUser[0].placeHolder[i].pos.length; j++) { - checkboxExist = - checkUser[0].placeHolder[i].pos[j].type === "checkbox"; - radioExist = - checkUser[0].placeHolder[i].pos[j].type === radioButtonWidget; - if (checkboxExist) { - requiredCheckbox = checkUser[0].placeHolder[i].pos.filter( - (position) => - !position.options?.isReadOnly && position.type === "checkbox" - ); + for (let i = 0; i < checkUser[0].placeHolder.length; i++) { + for (let j = 0; j < checkUser[0].placeHolder[i].pos.length; j++) { + checkboxExist = + checkUser[0].placeHolder[i].pos[j].type === "checkbox"; + radioExist = + checkUser[0].placeHolder[i].pos[j].type === radioButtonWidget; + if (checkboxExist) { + requiredCheckbox = checkUser[0].placeHolder[i].pos.filter( + (position) => + !position.options?.isReadOnly && position.type === "checkbox" + ); - if (requiredCheckbox && requiredCheckbox.length > 0) { - for (let i = 0; i < requiredCheckbox.length; i++) { - const minCount = - requiredCheckbox[i].options?.validation?.minRequiredCount; - const parseMin = minCount && parseInt(minCount); - const maxCount = - requiredCheckbox[i].options?.validation?.maxRequiredCount; - const parseMax = maxCount && parseInt(maxCount); - const response = - requiredCheckbox[i].options?.response?.length; - const defaultValue = - requiredCheckbox[i].options?.defaultValue?.length; - if (parseMin === 0 && parseMax === 0) { - if (!showAlert) { - showAlert = false; - setminRequiredCount(null); - } - } else if (parseMin === 0 && parseMax > 0) { - if (!showAlert) { - showAlert = false; - setminRequiredCount(null); - } - } else if (!response) { - if (!defaultValue) { - if (!showAlert) { - showAlert = true; - widgetKey = requiredCheckbox[i].key; - setminRequiredCount(parseMin); - } - } - } else if (parseMin > 0 && parseMin > response) { + if (requiredCheckbox && requiredCheckbox.length > 0) { + for (let i = 0; i < requiredCheckbox.length; i++) { + const minCount = + requiredCheckbox[i].options?.validation?.minRequiredCount; + const parseMin = minCount && parseInt(minCount); + const maxCount = + requiredCheckbox[i].options?.validation?.maxRequiredCount; + const parseMax = maxCount && parseInt(maxCount); + const response = requiredCheckbox[i].options?.response?.length; + const defaultValue = + requiredCheckbox[i].options?.defaultValue?.length; + if (parseMin === 0 && parseMax === 0) { + if (!showAlert) { + showAlert = false; + setminRequiredCount(null); + } + } else if (parseMin === 0 && parseMax > 0) { + if (!showAlert) { + showAlert = false; + setminRequiredCount(null); + } + } else if (!response) { + if (!defaultValue) { if (!showAlert) { showAlert = true; widgetKey = requiredCheckbox[i].key; setminRequiredCount(parseMin); } } + } else if (parseMin > 0 && parseMin > response) { + if (!showAlert) { + showAlert = true; + widgetKey = requiredCheckbox[i].key; + setminRequiredCount(parseMin); + } } } - } else if (radioExist) { - requiredRadio = checkUser[0].placeHolder[i].pos.filter( - (position) => - !position.options?.isReadOnly && - position.type === radioButtonWidget - ); - if (requiredRadio && requiredRadio?.length > 0) { - let checkSigned; - for (let i = 0; i < requiredRadio?.length; i++) { - checkSigned = requiredRadio[i]?.options.response; - if (!checkSigned) { - let checkDefaultSigned = - requiredRadio[i]?.options.defaultValue; + } + } else if (radioExist) { + requiredRadio = checkUser[0].placeHolder[i].pos.filter( + (position) => + !position.options?.isReadOnly && + position.type === radioButtonWidget + ); + if (requiredRadio && requiredRadio?.length > 0) { + let checkSigned; + for (let i = 0; i < requiredRadio?.length; i++) { + checkSigned = requiredRadio[i]?.options.response; + if (!checkSigned) { + let checkDefaultSigned = + requiredRadio[i]?.options.defaultValue; + if (!checkDefaultSigned) { + if (!showAlert) { + showAlert = true; + widgetKey = requiredRadio[i].key; + setminRequiredCount(null); + } + } + } + } + } + } else { + const requiredWidgets = checkUser[0].placeHolder[i].pos.filter( + (position) => + position.options?.status === "required" && + position.type !== radioButtonWidget && + position.type !== "checkbox" + ); + if (requiredWidgets && requiredWidgets?.length > 0) { + let checkSigned; + for (let i = 0; i < requiredWidgets?.length; i++) { + checkSigned = requiredWidgets[i]?.options?.response; + if (!checkSigned) { + const checkSignUrl = requiredWidgets[i]?.pos?.SignUrl; + + let checkDefaultSigned = + requiredWidgets[i]?.options?.defaultValue; + if (!checkSignUrl) { if (!checkDefaultSigned) { if (!showAlert) { showAlert = true; - widgetKey = requiredRadio[i].key; + widgetKey = requiredWidgets[i].key; setminRequiredCount(null); } } } } } - } else { - const requiredWidgets = checkUser[0].placeHolder[i].pos.filter( - (position) => - position.options?.status === "required" && - position.type !== radioButtonWidget && - position.type !== "checkbox" - ); - if (requiredWidgets && requiredWidgets?.length > 0) { - let checkSigned; - for (let i = 0; i < requiredWidgets?.length; i++) { - checkSigned = requiredWidgets[i]?.options?.response; - if (!checkSigned) { - const checkSignUrl = requiredWidgets[i]?.pos?.SignUrl; - - let checkDefaultSigned = - requiredWidgets[i]?.options?.defaultValue; - if (!checkSignUrl) { - if (!checkDefaultSigned) { - if (!showAlert) { - showAlert = true; - widgetKey = requiredWidgets[i].key; - setminRequiredCount(null); - } - } - } - } - } - } } } } + } - if (checkboxExist && requiredCheckbox && showAlert) { - setUnSignedWidgetId(widgetKey); - setWidgetsTour(true); - } else if (radioExist && showAlert) { - setUnSignedWidgetId(widgetKey); - setWidgetsTour(true); - } else if (showAlert) { - setUnSignedWidgetId(widgetKey); - setWidgetsTour(true); - } else { - setIsUiLoading(true); - const pngUrl = checkUser[0].placeHolder; - // Load a PDFDocument from the existing PDF bytes - const existingPdfBytes = await fetch(pdfUrl).then((res) => - res.arrayBuffer() - ); - const pdfDoc = await PDFDocument.load(existingPdfBytes, { - ignoreEncryption: true - }); - const flag = false; - const extUserPtr = pdfDetails[0].ExtUserPtr; - const HeaderDocId = extUserPtr?.HeaderDocId; - //embed document's object id to all pages in pdf document - if (!HeaderDocId) { - if (!isDocId) { - await embedDocId(pdfDoc, documentId, allPages); - } + if (checkboxExist && requiredCheckbox && showAlert) { + setUnSignedWidgetId(widgetKey); + setWidgetsTour(true); + } else if (radioExist && showAlert) { + setUnSignedWidgetId(widgetKey); + setWidgetsTour(true); + } else if (showAlert) { + setUnSignedWidgetId(widgetKey); + setWidgetsTour(true); + } else { + setIsUiLoading(true); + const pngUrl = checkUser[0].placeHolder; + // Load a PDFDocument from the existing PDF bytes + const existingPdfBytes = await fetch(pdfUrl).then((res) => + res.arrayBuffer() + ); + const pdfDoc = await PDFDocument.load(existingPdfBytes, { + ignoreEncryption: true + }); + const flag = false; + const extUserPtr = pdfDetails[0].ExtUserPtr; + const HeaderDocId = extUserPtr?.HeaderDocId; + //embed document's object id to all pages in pdf document + if (!HeaderDocId) { + if (!isDocId) { + await embedDocId(pdfDoc, documentId, allPages); } - //embed multi signature in pdf - const pdfBytes = await multiSignEmbed( - pngUrl, - pdfDoc, - pdfOriginalWidth, - flag, - containerWH + } + //embed multi signature in pdf + const pdfBytes = await multiSignEmbed( + pngUrl, + pdfDoc, + pdfOriginalWidth, + flag, + containerWH + ); + //get ExistUserPtr object id of user class to get tenantDetails + const objectId = pdfDetails?.[0]?.ExtUserPtr?.UserId?.objectId; + //function for call to embed signature in pdf and get digital signature pdf + try { + const res = await signPdfFun( + pdfBytes, + documentId, + signerObjectId, + setIsAlert, + objectId, + isSubscribed ); - //get ExistUserPtr object id of user class to get tenantDetails - const objectId = pdfDetails?.[0]?.ExtUserPtr?.UserId?.objectId; - //function for call to embed signature in pdf and get digital signature pdf - try { - const res = await signPdfFun( - pdfBytes, - documentId, - signerObjectId, - setIsAlert, - objectId, - isSubscribed - ); - if (res && res.status === "success") { - setPdfUrl(res.data); - setIsSigned(true); - setSignedSigners([]); - setUnSignedSigners([]); - getDocumentDetails(); - if (sendInOrder) { - const index = pdfDetails?.[0].Signers.findIndex( - (x) => x.Email === jsonSender.email - ); - const requestBody = pdfDetails?.[0]?.RequestBody; - const requestSubject = pdfDetails?.[0]?.RequestSubject; + if (res && res.status === "success") { + setPdfUrl(res.data); + setIsSigned(true); + setSignedSigners([]); + setUnSignedSigners([]); + getDocumentDetails(); + if (sendInOrder) { + const index = pdfDetails?.[0].Signers.findIndex( + (x) => x.Email === jsonSender.email + ); + const requestBody = pdfDetails?.[0]?.RequestBody; + const requestSubject = pdfDetails?.[0]?.RequestSubject; - const newIndex = index + 1; - const user = pdfDetails?.[0].Signers[newIndex]; - if (user) { - const expireDate = pdfDetails?.[0].ExpiryDate.iso; - const newDate = new Date(expireDate); - const localExpireDate = newDate.toLocaleDateString("en-US", { - day: "numeric", - month: "long", - year: "numeric" - }); - let senderEmail = pdfDetails?.[0].ExtUserPtr.Email; - let senderPhone = pdfDetails?.[0]?.ExtUserPtr?.Phone; - const senderName = `${pdfDetails?.[0].ExtUserPtr.Name}`; + const newIndex = index + 1; + const user = pdfDetails?.[0].Signers[newIndex]; + if (user) { + const expireDate = pdfDetails?.[0].ExpiryDate.iso; + const newDate = new Date(expireDate); + const localExpireDate = newDate.toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric" + }); + let senderEmail = pdfDetails?.[0].ExtUserPtr.Email; + let senderPhone = pdfDetails?.[0]?.ExtUserPtr?.Phone; + const senderName = `${pdfDetails?.[0].ExtUserPtr.Name}`; - try { - const imgPng = - "https://qikinnovation.ams3.digitaloceanspaces.com/logo.png"; - let url = `${localStorage.getItem( - "baseUrl" - )}functions/sendmailv3/`; - const headers = { - "Content-Type": "application/json", - "X-Parse-Application-Id": - localStorage.getItem("parseAppId"), - sessionToken: localStorage.getItem("accesstoken") + try { + const imgPng = + "https://qikinnovation.ams3.digitaloceanspaces.com/logo.png"; + let url = `${localStorage.getItem( + "baseUrl" + )}functions/sendmailv3/`; + const headers = { + "Content-Type": "application/json", + "X-Parse-Application-Id": + localStorage.getItem("parseAppId"), + sessionToken: localStorage.getItem("accesstoken") + }; + const serverUrl = localStorage.getItem("baseUrl"); + const newServer = serverUrl.replaceAll("/", "%2F"); + const objectId = user.objectId; + const serverParams = `${newServer}&${localStorage.getItem( + "parseAppId" + )}&${localStorage.getItem("_appName")}`; + const hostUrl = window.location.origin; + let signPdf = `${hostUrl}/login/${pdfDetails?.[0].objectId}/${user.Email}/${objectId}/${serverParams}`; + const openSignUrl = "https://www.opensignlabs.com/contact-us"; + const orgName = pdfDetails[0]?.ExtUserPtr.Company + ? pdfDetails[0].ExtUserPtr.Company + : ""; + const themeBGcolor = themeColor; + let replaceVar; + if ( + requestBody && + requestSubject && + (!isEnableSubscription || isSubscribed) + ) { + const replacedRequestBody = requestBody.replace(/"/g, "'"); + const htmlReqBody = + "
" + + replacedRequestBody + + " "; + + const variables = { + document_title: pdfDetails?.[0].Name, + sender_name: senderName, + sender_mail: senderEmail, + sender_phone: senderPhone, + receiver_name: user.Name, + receiver_email: user.Email, + receiver_phone: user.Phone, + expiry_date: localExpireDate, + company_name: orgName, + signing_url: `Sign here` }; - const serverUrl = localStorage.getItem("baseUrl"); - const newServer = serverUrl.replaceAll("/", "%2F"); - const objectId = user.objectId; - const serverParams = `${newServer}&${localStorage.getItem( - "parseAppId" - )}&${localStorage.getItem("_appName")}`; - const hostUrl = window.location.origin; - let signPdf = `${hostUrl}/login/${pdfDetails?.[0].objectId}/${user.Email}/${objectId}/${serverParams}`; - const openSignUrl = - "https://www.opensignlabs.com/contact-us"; - const orgName = pdfDetails[0]?.ExtUserPtr.Company - ? pdfDetails[0].ExtUserPtr.Company - : ""; - const themeBGcolor = themeColor; - let replaceVar; - if ( - requestBody && - requestSubject && - (!isEnableSubscription || isSubscribed) - ) { - const replacedRequestBody = requestBody.replace( - /"/g, - "'" - ); - const htmlReqBody = - "" + - replacedRequestBody + - " "; - - const variables = { - document_title: pdfDetails?.[0].Name, - sender_name: senderName, - sender_mail: senderEmail, - sender_phone: senderPhone, - receiver_name: user.Name, - receiver_email: user.Email, - receiver_phone: user.Phone, - expiry_date: localExpireDate, - company_name: orgName, - signing_url: `Sign here` - }; - replaceVar = replaceMailVaribles( - requestSubject, - htmlReqBody, - variables - ); - } - - let params = { - extUserId: extUserId, - recipient: user.Email, - subject: requestSubject - ? replaceVar?.subject - : `${pdfDetails?.[0].ExtUserPtr.Name} has requested you to sign ${pdfDetails?.[0].Name}`, - from: senderEmail, - html: requestBody - ? replaceVar?.body - : "Digital Signature Request
This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender " + - senderEmail + - " directly.If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ here.
Digital Signature Request
This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender " + + senderEmail + + " directly.If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ here.
- Are you sure you want to send out this document for - signatures? -
- <> + {!isCustomize && ( + + Are you sure you want to send out this document + for signatures? + + )} + {isCustomize && + (!isEnableSubscription || isSubscribe) && ( + <> +