From 9fa97f27f07147a040cd43a80d651c832b2bc118 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Thu, 8 Aug 2024 15:55:11 +0530 Subject: [PATCH 1/9] fix: error in auto-sign feature unexpected issue encountered - something went wrong --- .../src/components/pdf/EmailComponent.js | 60 +- apps/OpenSign/src/constant/Utils.js | 49 +- apps/OpenSign/src/pages/PdfRequestFiles.js | 539 +++++++++--------- apps/OpenSign/src/pages/SignyourselfPdf.js | 229 ++++---- 4 files changed, 437 insertions(+), 440 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/EmailComponent.js b/apps/OpenSign/src/components/pdf/EmailComponent.js index a41f82cbb..77ee86b9c 100644 --- a/apps/OpenSign/src/components/pdf/EmailComponent.js +++ b/apps/OpenSign/src/components/pdf/EmailComponent.js @@ -1,7 +1,11 @@ import React, { useState } from "react"; import { saveAs } from "file-saver"; import axios from "axios"; -import { getBase64FromUrl } from "../../constant/Utils"; +import { + getBase64FromUrl, + handleDownloadPdf, + handleToPrint +} from "../../constant/Utils"; import { themeColor, emailRegex } from "../../constant/const"; import printModule from "print-js"; import Loader from "../../primitives/Loader"; @@ -13,7 +17,7 @@ function EmailComponent({ pdfUrl, setIsEmail, setSuccessEmail, - pdfName, + pdfDetails, sender, setIsAlert, extUserId, @@ -24,10 +28,12 @@ function EmailComponent({ const [emailValue, setEmailValue] = useState(""); const [isLoading, setIsLoading] = useState(false); const [emailErr, setEmailErr] = useState(false); + const [isDownloading, setIsDownloading] = useState(""); + const isAndroid = /Android/i.test(navigator.userAgent); //function for send email const sendEmail = async () => { + const pdfName = pdfDetails[0]?.Name; setIsLoading(true); - let sendMail; for (let i = 0; i < emailList.length; i++) { try { @@ -140,43 +146,6 @@ function EmailComponent({ } } }; - - // function for print signed pdf - const handleToPrint = async (event) => { - event.preventDefault(); - - const pdf = await getBase64FromUrl(pdfUrl); - const isAndroidDevice = navigator.userAgent.match(/Android/i); - const isAppleDevice = - (/iPad|iPhone|iPod/.test(navigator.platform) || - (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) && - !window.MSStream; - if (isAndroidDevice || isAppleDevice) { - const byteArray = Uint8Array.from( - atob(pdf) - .split("") - .map((char) => char.charCodeAt(0)) - ); - const blob = new Blob([byteArray], { type: "application/pdf" }); - const blobUrl = URL.createObjectURL(blob); - window.open(blobUrl, "_blank"); - } else { - printModule({ printable: pdf, type: "pdf", base64: true }); - } - }; - - //handle download signed pdf - const handleDownloadPdf = () => { - saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`); - }; - - const sanitizeFileName = (pdfName) => { - // Replace spaces with underscore - return pdfName.replace(/ /g, "_"); - }; - - const isAndroid = /Android/i.test(navigator.userAgent); - return (
{/* isEmail */} @@ -190,6 +159,11 @@ function EmailComponent({
)} + {isDownloading === "pdf" && ( +
+ +
+ )}
{t("successfully-signed")} @@ -197,7 +171,7 @@ function EmailComponent({
{!isAndroid && (
@@ -1765,7 +1765,7 @@ function PdfRequestFiles(props) { name="name" value={contact.name} onChange={handleInputChange} - placeholder="name" + placeholder={t("name")} onInvalid={(e) => e.target.setCustomValidity(t("input-required")) } @@ -1790,7 +1790,7 @@ function PdfRequestFiles(props) { name="email" value={contact.email} onChange={handleInputChange} - placeholder="Email" + placeholder={t("email")} onInvalid={(e) => e.target.setCustomValidity(t("input-required")) } @@ -1815,7 +1815,7 @@ function PdfRequestFiles(props) { type="text" name="phone" className="grow" - placeholder="phone" + placeholder={t("phone")} disabled={loading} /> @@ -1828,13 +1828,13 @@ function PdfRequestFiles(props) { handleCloseOtp(); }} > - Close + {t("close")} diff --git a/apps/OpenSign/src/script/PublicTemplate.js b/apps/OpenSign/src/script/PublicTemplate.js index 3ef08df4c..b512e2670 100644 --- a/apps/OpenSign/src/script/PublicTemplate.js +++ b/apps/OpenSign/src/script/PublicTemplate.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import Parse from "parse"; import ReactDOM from "react-dom/client"; import PdfRequestFiles from "../pages/PdfRequestFiles"; @@ -6,6 +6,8 @@ import { pdfjs } from "react-pdf"; import { Provider } from "react-redux"; import { store } from "../redux/store"; import "../index.css"; +import "../i18n"; +import { isPublicStaging } from "../constant/const"; pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.mjs`; // Wrapper component to manage props @@ -13,15 +15,22 @@ const PublicScriptFileWrapper = ({ initialProps }) => { const [props, setProps] = useState(initialProps); // Make the setProps function globally accessible - window.updatePublicTemplateProps = setProps; + useEffect(() => { + window.updatePublicTemplateProps = setProps; + + return () => { + window.updatePublicTemplateProps = undefined; + }; + }, []); return ; }; -const appId = "legadranaxn"; -// "opensign"; -const serverUrl = "https://app.opensignlabs.com/api/app"; -// "https://staging-app.opensignlabs.com/api/app"; +const appId = isPublicStaging ? "opensign" : "legadranaxn"; +const serverUrl = isPublicStaging + ? "https://staging-app.opensignlabs.com/api/app" + : "https://app.opensignlabs.com/api/app"; + localStorage.setItem("baseUrl", `${serverUrl}/`); localStorage.setItem("parseAppId", appId); Parse.initialize(appId); @@ -38,9 +47,8 @@ document.head.appendChild(link); //add the Tailwind CSS file const tailwindCssLink = document.createElement("link"); tailwindCssLink.href = - "https://app.opensignlabs.com/static/js/public-template.bundle.css"; // css bundle file -// "https://staging-app.opensignlabs.com/static/js/public-template.bundle.css"; // css bundle file -tailwindCssLink.rel = "stylesheet"; + // "https://app.opensignlabs.com/static/js/public-template.bundle.css"; // css bundle file + tailwindCssLink.rel = "stylesheet"; document.head.appendChild(tailwindCssLink); // Create a root and render the wrapper component with initial props const root = ReactDOM.createRoot(document.getElementById("script-component")); diff --git a/apps/OpenSign/webpack.config.js b/apps/OpenSign/webpack.config.js index 54967737e..f4c76810f 100644 --- a/apps/OpenSign/webpack.config.js +++ b/apps/OpenSign/webpack.config.js @@ -50,7 +50,7 @@ module.exports = { ] }, resolve: { - extensions: [".js", ".jsx"] + extensions: [".js", ".jsx", ".json"] }, plugins: [ new Dotenv(), From 00e6ea5b3b77635bdbdafe72ed6797098f0bf0c8 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 9 Aug 2024 15:31:57 +0530 Subject: [PATCH 7/9] fix: resolve warning --- apps/OpenSign/src/constant/const.js | 5 ++-- apps/OpenSign/src/i18n.js | 8 +++--- apps/OpenSign/src/pages/PlaceHolderSign.js | 25 ++++++++----------- apps/OpenSign/src/pages/TeamList.js | 1 + apps/OpenSign/src/pages/UserList.js | 1 + apps/OpenSign/src/pages/UserProfile.js | 1 + apps/OpenSign/src/primitives/ValidateRoute.js | 1 + 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/OpenSign/src/constant/const.js b/apps/OpenSign/src/constant/const.js index 850980ece..f5a7babe8 100644 --- a/apps/OpenSign/src/constant/const.js +++ b/apps/OpenSign/src/constant/const.js @@ -11,8 +11,7 @@ export const isEnableSubscription = : false; export const isStaging = window.location.origin === "https://staging-app.opensignlabs.com"; -export const isPublic = - window.location.origin === "https://opensign.me" || - window.location.origin === "https://staging.opensign.me"; +export const isPublicProduction = + window.location.origin === "https://opensign.me"; export const isPublicStaging = window.location.origin === "https://staging.opensign.me"; diff --git a/apps/OpenSign/src/i18n.js b/apps/OpenSign/src/i18n.js index 0cd8692f8..3d9e3adfd 100644 --- a/apps/OpenSign/src/i18n.js +++ b/apps/OpenSign/src/i18n.js @@ -2,12 +2,14 @@ import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import Backend from "i18next-http-backend"; import LanguageDetector from "i18next-browser-languagedetector"; -import { isPublic } from "./constant/const"; +import { isPublicProduction, isPublicStaging } from "./constant/const"; //handle path to support language on public profile -const backendPath = isPublic +const backendPath = isPublicStaging ? "https://staging-app.opensignlabs.com/locales/{{lng}}/{{ns}}.json" - : "/locales/{{lng}}/{{ns}}.json"; + : isPublicProduction + ? "https://app.opensignlabs.com/locales/{{lng}}/{{ns}}.json" + : "/locales/{{lng}}/{{ns}}.json"; i18n .use(Backend) diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js index 04831ea19..f1fbf810b 100644 --- a/apps/OpenSign/src/pages/PlaceHolderSign.js +++ b/apps/OpenSign/src/pages/PlaceHolderSign.js @@ -190,28 +190,20 @@ function PlaceHolderSign() { if (user) { try { + const defaultRequestBody = `

Hi {{receiver_name}},


We hope this email finds you well. {{sender_name}} has requested you to review and sign {{document_title}}.

Your signature is crucial to proceed with the next steps as it signifies your agreement and authorization.


{{signing_url}}


If you have any questions or need further clarification regarding the document or the signing process, please contact the sender.


Thanks

Team OpenSign™


`; + const defaultSubject = `{{sender_name}} has requested you to sign {{document_title}}`; + setDefaultBody(defaultRequestBody); + setDefaultSubject(defaultSubject); const tenantDetails = await getTenantDetails(user?.objectId); if (tenantDetails && tenantDetails === "user does not exist!") { alert(t("user-not-exist")); } else if (tenantDetails) { - const defaultRequestBody = `

Hi {{receiver_name}},


We hope this email finds you well. {{sender_name}} has requested you to review and sign {{document_title}}.

Your signature is crucial to proceed with the next steps as it signifies your agreement and authorization.


{{signing_url}}


If you have any questions or need further clarification regarding the document or the signing process, please contact the sender.


Thanks

Team OpenSign™


`; if (tenantDetails?.RequestBody) { setRequestBody(tenantDetails?.RequestBody); setRequestSubject(tenantDetails?.RequestSubject); - - setDefaultBody(defaultRequestBody); - setDefaultSubject( - `{{sender_name}} has requested you to sign {{document_title}}` - ); } else { setRequestBody(defaultRequestBody); - setRequestSubject( - `{{sender_name}} has requested you to sign {{document_title}}` - ); - setDefaultBody(defaultRequestBody); - setDefaultSubject( - `{{sender_name}}has requested you to sign {{document_title}}` - ); + setRequestSubject(defaultSubject); } } } catch (e) { @@ -222,6 +214,7 @@ function PlaceHolderSign() { } }; + console.log("default body", defaultBody); useEffect(() => { const updateSize = () => { if (divRef.current) { @@ -1772,8 +1765,10 @@ function PlaceHolderSign() { <> diff --git a/apps/OpenSign/src/pages/TeamList.js b/apps/OpenSign/src/pages/TeamList.js index 65e7359e6..d4b4eb063 100644 --- a/apps/OpenSign/src/pages/TeamList.js +++ b/apps/OpenSign/src/pages/TeamList.js @@ -97,6 +97,7 @@ const TeamList = () => { const pageNumbers = getPaginationRange(); useEffect(() => { fetchTeamList(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); async function fetchTeamList() { try { diff --git a/apps/OpenSign/src/pages/UserList.js b/apps/OpenSign/src/pages/UserList.js index 3d07febe1..9d38d154c 100644 --- a/apps/OpenSign/src/pages/UserList.js +++ b/apps/OpenSign/src/pages/UserList.js @@ -85,6 +85,7 @@ const UserList = () => { const pageNumbers = getPaginationRange(); useEffect(() => { fetchUserList(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); async function fetchUserList() { try { diff --git a/apps/OpenSign/src/pages/UserProfile.js b/apps/OpenSign/src/pages/UserProfile.js index 1c383d840..0ef940688 100644 --- a/apps/OpenSign/src/pages/UserProfile.js +++ b/apps/OpenSign/src/pages/UserProfile.js @@ -57,6 +57,7 @@ function UserProfile() { useEffect(() => { getUserDetail(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const getUserDetail = async () => { diff --git a/apps/OpenSign/src/primitives/ValidateRoute.js b/apps/OpenSign/src/primitives/ValidateRoute.js index 23caa01ca..e0af692b6 100644 --- a/apps/OpenSign/src/primitives/ValidateRoute.js +++ b/apps/OpenSign/src/primitives/ValidateRoute.js @@ -23,6 +23,7 @@ const ValidateRoute = () => { } } })(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const handlelogout = async () => { let appdata = localStorage.getItem("userSettings"); From f4466dc3250e710c0f21c73b700059bf3601c1b4 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 9 Aug 2024 15:41:35 +0530 Subject: [PATCH 8/9] fix: resolve public url --- apps/OpenSign/src/pages/UserProfile.js | 6 ++++-- apps/OpenSign/src/primitives/GetReportDisplay.js | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/OpenSign/src/pages/UserProfile.js b/apps/OpenSign/src/pages/UserProfile.js index 0ef940688..df42f0e0b 100644 --- a/apps/OpenSign/src/pages/UserProfile.js +++ b/apps/OpenSign/src/pages/UserProfile.js @@ -7,7 +7,7 @@ import Title from "../components/Title"; import sanitizeFileName from "../primitives/sanitizeFileName"; import axios from "axios"; import Tooltip from "../primitives/Tooltip"; -import { isEnableSubscription } from "../constant/const"; +import { isEnableSubscription, isStaging } from "../constant/const"; import { checkIsSubscribed, checkIsSubscribedTeam, @@ -476,7 +476,9 @@ function UserProfile() { />
- opensign.me/ + + {isStaging ? "staging.opensign.me/" : " opensign.me/"} + {editmode ? ( { } }; + const publicUrl = () => { + const subDomain = isStaging + ? `https://staging.opensign.me/` + : `https://opensign.me/`; + const url = `${subDomain}${publicUserName}`; + return url; + }; // function to copy public profile links const copytoProfileLink = () => { - const url = `https://opensign.me/${publicUserName}`; + const url = publicUrl(); copytoData(url); setIsAlert(true); setAlertMsg({ @@ -1326,7 +1333,9 @@ const ReportTable = (props) => { copytoProfileLink()} className="underline underline-offset-2 w-[150px] md:w-[350px] whitespace-nowrap overflow-hidden text-ellipsis cursor-pointer" - >{`https://opensign.me/${publicUserName}`} + > + {publicUrl()} +
) : ( From d20913023e42fc9b521555c226a876323270c692 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 9 Aug 2024 16:25:22 +0530 Subject: [PATCH 9/9] fix: email condition issue in adduser file --- apps/OpenSign/src/components/AddUser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/OpenSign/src/components/AddUser.js b/apps/OpenSign/src/components/AddUser.js index 4bf1f335a..2bdd3f5f5 100644 --- a/apps/OpenSign/src/components/AddUser.js +++ b/apps/OpenSign/src/components/AddUser.js @@ -240,10 +240,14 @@ const AddUser = (props) => { props.closePopup(); } }; - const handleChange = (e) => { + const handleChange = (event) => { + let { name, value } = event.target; + if (name === "email") { + value = value?.toLowerCase()?.replace(/\s/g, ""); + } setFormdata((prev) => ({ ...prev, - [e.target.name]: e.target.value?.toLowerCase()?.replace(/\s/g, "") + [name]: value })); };