diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js index 35553130f..87627b968 100644 --- a/apps/OpenSign/src/json/ReportJson.js +++ b/apps/OpenSign/src/json/ReportJson.js @@ -85,6 +85,14 @@ export default function reportJson(id) { btnIcon: "fa-solid fa-ellipsis-vertical fa-lg", action: "option", subaction: [ + { + btnId: "1630", + btnLabel: "Resend", + hoverLabel: "Resend", + btnIcon: "fa-solid fa-envelope", + redirectUrl: "", + action: "resend" + }, { btnId: "1688", btnLabel: "Revoke", diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js index 927a0e14f..e5e603d74 100644 --- a/apps/OpenSign/src/primitives/GetReportDisplay.js +++ b/apps/OpenSign/src/primitives/GetReportDisplay.js @@ -11,6 +11,13 @@ import { RWebShare } from "react-web-share"; import Tour from "reactour"; import Parse from "parse"; import { saveAs } from "file-saver"; +import { replaceMailVaribles } from "../constant/Utils"; +import EditorToolbar, { + module1, + formats +} from "../components/pdf/EditorToolbar"; +import ReactQuill from "react-quill"; +import "react-quill/dist/quill.snow.css"; const ReportTable = (props) => { const navigate = useNavigate(); @@ -28,6 +35,10 @@ const ReportTable = (props) => { const [alertMsg, setAlertMsg] = useState({ type: "success", message: "" }); const [isTour, setIsTour] = useState(false); const [tourStatusArr, setTourStatusArr] = useState([]); + const [isResendMail, setIsResendMail] = useState({}); + const [mail, setMail] = useState({ subject: "", body: "" }); + const [userDetails, setUserDetails] = useState({}); + const [isNextStep, setIsNextStep] = useState({}); const startIndex = (currentPage - 1) * props.docPerPage; const { isMoreDocs, setIsNextRecord } = props; // For loop is used to calculate page numbers visible below table @@ -89,8 +100,6 @@ const ReportTable = (props) => { } } ); - - // console.log("templateDeatils.data ", templateDeatils.data); const templateData = templateDeatils.data && templateDeatils.data.result; if (!templateData.error) { @@ -149,7 +158,6 @@ const ReportTable = (props) => { } ); - // console.log("Res ", res.data); if (res.data && res.data.objectId) { setActLoader({}); setIsAlert(true); @@ -210,6 +218,8 @@ const ReportTable = (props) => { setIsRevoke({ [item.objectId]: true }); } else if (act.action === "option") { setIsOption({ [item.objectId]: !isOption[item.objectId] }); + } else if (act.action === "resend") { + setIsResendMail({ [item.objectId]: true }); } }; // Get current list @@ -254,7 +264,6 @@ const ReportTable = (props) => { "X-Parse-Session-Token": localStorage.getItem("accesstoken") } }); - // console.log("Res ", res.data); if (res.data && res.data.updatedAt) { setActLoader({}); setIsAlert(true); @@ -437,6 +446,161 @@ const ReportTable = (props) => { } } }; + + // `handleSubjectChange` is used to add or change subject of resend mail + const handleSubjectChange = (subject, doc) => { + const encodeBase64 = btoa( + `${doc.objectId}/${userDetails.Email}/${userDetails.objectId}` + ); + const expireDate = doc.ExpiryDate.iso; + const newDate = new Date(expireDate); + const localExpireDate = newDate.toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric" + }); + const signPdf = `${window.location.origin}/login/${encodeBase64}`; + const variables = { + document_title: doc.Name, + sender_name: doc.ExtUserPtr.Name, + sender_mail: doc.ExtUserPtr.Email, + sender_phone: doc.ExtUserPtr.Phone, + receiver_name: userDetails.Name, + receiver_email: userDetails.Email, + receiver_phone: userDetails.Phone, + expiry_date: localExpireDate, + company_name: doc.ExtUserPtr.Company, + signing_url: `Sign here` + }; + const res = replaceMailVaribles(subject, "", variables); + + setMail((prev) => ({ ...prev, subject: res.subject })); + }; + // `handlebodyChange` is used to add or change body of resend mail + const handlebodyChange = (body, doc) => { + const encodeBase64 = btoa( + `${doc.objectId}/${userDetails.Email}/${userDetails.objectId}` + ); + const expireDate = doc.ExpiryDate.iso; + const newDate = new Date(expireDate); + const localExpireDate = newDate.toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric" + }); + const signPdf = `${window.location.origin}/login/${encodeBase64}`; + const variables = { + document_title: doc.Name, + sender_name: doc.ExtUserPtr.Name, + sender_mail: doc.ExtUserPtr.Email, + sender_phone: doc.ExtUserPtr.Phone, + receiver_name: userDetails.Name, + receiver_email: userDetails.Email, + receiver_phone: userDetails.Phone, + expiry_date: localExpireDate, + company_name: doc.ExtUserPtr.Company, + signing_url: `Sign here` + }; + const res = replaceMailVaribles("", body, variables); + + if (body) { + setMail((prev) => ({ ...prev, body: res.body })); + } + }; + // `handleNextBtn` is used to open edit mail template screen in resend mail modal + // as well as replace variable with original one + const handleNextBtn = (user, doc) => { + setUserDetails(user); + const encodeBase64 = btoa(`${doc.objectId}/${user.Email}/${user.objectId}`); + const expireDate = doc.ExpiryDate.iso; + const newDate = new Date(expireDate); + const localExpireDate = newDate.toLocaleDateString("en-US", { + day: "numeric", + month: "long", + year: "numeric" + }); + const signPdf = `${window.location.origin}/login/${encodeBase64}`; + const variables = { + document_title: doc.Name, + sender_name: doc.ExtUserPtr.Name, + sender_mail: doc.ExtUserPtr.Email, + sender_phone: doc.ExtUserPtr.Phone, + receiver_name: user.Name, + receiver_email: user.Email, + receiver_phone: user.Phone, + expiry_date: localExpireDate, + company_name: doc.ExtUserPtr.Company, + signing_url: `Sign here` + }; + + const subject = + doc?.RequestSubject || + "{{sender_name}} has requested you to sign {{document_title}}"; + const body = + doc?.RequestBody || + "
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™