🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix Completion certificate issues (#184)
Raktimaa14454227c26
diff --git a/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js b/microfrontends/SignDocuments/src/Component/Certificate/Certificate.jsindex 5df07d5f5..37eee4fc3 100644--- a/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js+++ b/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js@@ -1,7 +1,15 @@import React, { useEffect, useState } from "react";import "./certificate.css";+import opensignLogo from "../../assests/open-sign-logo.png";-import { Page, Text, View, Document, StyleSheet } from "@react-pdf/renderer";+import {+ Page,+ Text,+ View,+ Document,+ StyleSheet,+ Image+} from "@react-pdf/renderer";function Certificate({ pdfData }) {const [isMultiSigners, setIsMultiSigners] = useState();@@ -49,70 +57,34 @@ function Certificate({ pdfData }) {fontSize: "11px",marginBottom: "10px",color: "gray"+ },+ image: {+ width: "71px",+ height: "17px"}});const generatedDate = () => {const newDate = new Date();- const localExpireDate = newDate.toLocaleDateString("en-US", {- day: "numeric",- month: "long",- year: "numeric"- });-- var currentOffset = newDate.getTimezoneOffset();-- var ISTOffset = 330; // IST offset UTC +5:30-- var ISTTime = new Date(- newDate.getTime() + (ISTOffset + currentOffset) * 60000- );-- // ISTTime now represents the time in IST coordinates-- var hoursIST = ISTTime.getHours();- var minutesIST = ISTTime.getMinutes();+ const utcTime = newDate.toUTCString();return (<Textstyle={{- textAlign: "right",color: "gray",- fontSize: "10px",- marginBottom: "30px"+ fontSize: "10px"}}>- Generated On {localExpireDate} {hoursIST}:{minutesIST} IST+ Generated On {utcTime}</Text>);};const changeCompletedDate = () => {const completedOn = pdfData[0].updatedAt;const newDate = new Date(completedOn);- const localExpireDate = newDate.toLocaleDateString("en-US", {- day: "numeric",- month: "long",- year: "numeric"- });-- var currentOffset = newDate.getTimezoneOffset();+ const utcTime = newDate.toUTCString();- var ISTOffset = 330; // IST offset UTC +5:30-- var ISTTime = new Date(- newDate.getTime() + (ISTOffset + currentOffset) * 60000- );-- // ISTTime now represents the time in IST coordinates-- var hoursIST = ISTTime.getHours();- var minutesIST = ISTTime.getMinutes();-- return (- <Text style={styles.textStyle2}>- {localExpireDate} {hoursIST}:{minutesIST} IST- </Text>- );+ return <Text style={styles.textStyle2}>{utcTime}</Text>;};const signerName = (data) => {@@ -143,7 +115,19 @@ function Certificate({ pdfData }) {{/** Page defines a single page of content. */}<Page size="A4" style={styles.page}><View style={styles.section1}>- {generatedDate()}+ <View+ style={{+ display: "flex",+ flexDirection: "row",+ justifyContent: "space-between",+ alignItems: "center",+ marginBottom: "30px"+ }}+ >+ <Image src={opensignLogo} style={styles.image} />+ {generatedDate()}+ </View>+<View style={{ justifyContent: "center" }}><Textstyle={{@@ -182,7 +166,9 @@ function Certificate({ pdfData }) {</Text><Text style={styles.textStyle}>Organization : - <Text style={styles.textStyle2}>__</Text>+ <Text style={styles.textStyle2}>+ {pdfData[0].ExtUserPtr.Company}+ </Text></Text><Text style={styles.textStyle}>Completed on : {changeCompletedDate()}diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.jsindex d4cb37df9..6591667bc 100644--- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js+++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js@@ -627,8 +627,8 @@ function SignYourSelf() {const bottomY = xyPosData.isDrag? xyPosData.yBottom * scale - height: xyPosData.firstYPos- ? xyPosData.yBottom * scale - height + xyPosData.firstYPos- : xyPosData.yBottom * scale - height;+ ? xyPosData.yBottom * scale - height + xyPosData.firstYPos+ : xyPosData.yBottom * scale - height;singleSign = {pdfFile: pdfBase64Url,@@ -664,15 +664,7 @@ function SignYourSelf() {// console.log("json ", json);setPdfUrl(json.result.data);if (json.result.data) {- const docStatus = {- isCompleted: true- };-- setDocumentStatus(docStatus);- const loadObj = {- isLoad: false- };- setIsLoading(loadObj);+ getDocumentDetails();}}).catch((err) => {diff --git a/microfrontends/SignDocuments/src/Component/component/header.js b/microfrontends/SignDocuments/src/Component/component/header.jsindex 4d971cfb4..d7f4724ed 100644--- a/microfrontends/SignDocuments/src/Component/component/header.js+++ b/microfrontends/SignDocuments/src/Component/component/header.js@@ -82,13 +82,13 @@ function Header({//handle download signed pdfconst handleDownloadPdf = () => {const pdfName = pdfDetails[0] && pdfDetails[0].Name;- saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSignâ„¢.pdf`);+ saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSignâ„¢.pdf`);};-+const sanitizeFileName = (pdfName) => {// Replace spaces with underscore- return pdfName.replace(/ /g, '_');- }+ return pdfName.replace(/ /g, "_");+ };//certificate generate and download component in mobile viewconst CertificateDropDown = () => {//after generate download certifcate pdf@@ -109,6 +109,7 @@ function Header({window.URL.revokeObjectURL(url);}};+return (<PDFDownloadLinkonClick={(e) => e.preventDefault()}@@ -118,7 +119,21 @@ function Header({{({ blob, url, loading, error }) => (<>{loading ? (- "Loading document..."+ <div+ style={{+ border: "none",+ backgroundColor: "#fff"+ }}+ >+ <i+ className="fa fa-certificate"+ style={{+ marginRight: "2px"+ }}+ aria-hidden="true"+ ></i>+ Certificate+ </div>) : (<divstyle={{@@ -149,6 +164,63 @@ function Header({</PDFDownloadLink>);};+ const CertificateComponent = () => {+ return (+ <PDFDownloadLink+ style={{ textDecoration: "none" }}+ document={<Certificate pdfData={pdfDetails} />}+ fileName={`completion certificate-${+ pdfDetails[0] && pdfDetails[0].Name+ }.pdf`}+ >+ {({ blob, url, loading, error }) =>+ loading ? (+ <button+ type="button"+ className="defaultBtn certificateBtn"+ style={{+ display: "flex",+ flexDirection: "row",+ alignItems: "center"+ }}+ >+ <i+ className="fa fa-certificate"+ style={{+ color: "white",+ fontSize: "15px",+ marginRight: "3px"+ }}+ aria-hidden="true"+ ></i>+ Certificate+ </button>+ ) : (+ <button+ type="button"+ className="defaultBtn certificateBtn"+ style={{+ display: "flex",+ flexDirection: "row",+ alignItems: "center"+ }}+ >+ <i+ className="fa fa-certificate"+ style={{+ color: "white",+ fontSize: "15px",+ marginRight: "3px"+ }}+ aria-hidden="true"+ ></i>+ Certificate+ </button>+ )+ }+ </PDFDownloadLink>+ );+ };return (<divstyle={{ padding: !isGuestSigner && "5px 0px 5px 0px" }}@@ -215,7 +287,7 @@ function Header({border: "none",fontWeight: "650",fontSize: "16px",- padding:"0px 3px 0px 5px"+ padding: "0px 3px 0px 5px"}}><i className="fa fa-ellipsis-v" aria-hidden="true"></i>@@ -255,10 +327,12 @@ function Header({<DropdownMenu.Item className="DropdownMenuItem"><CertificateDropDown /></DropdownMenu.Item>- ) :isSignYourself && (- <DropdownMenu.Item className="DropdownMenuItem">- <CertificateDropDown />- </DropdownMenu.Item>+ ) : (+ isSignYourself && (+ <DropdownMenu.Item className="DropdownMenuItem">+ <CertificateDropDown />+ </DropdownMenu.Item>+ ))}<DropdownMenu.ItemclassName="DropdownMenuItem"@@ -360,40 +434,7 @@ function Header({pdfUrl || isAlreadySign.mssg ? (<div style={{ display: "flex", flexDirection: "row" }}>{pdfDetails[0] && pdfDetails.length > 0 && (- <PDFDownloadLink- style={{ textDecoration: "none" }}- document={<Certificate pdfData={pdfDetails} />}- fileName={`completion certificate-${- pdfDetails[0] && pdfDetails[0].Name- }.pdf`}- >- {({ blob, url, loading, error }) =>- loading ? (- "Loading document..."- ) : (- <button- type="button"- className="defaultBtn certificateBtn"- style={{- display: "flex",- flexDirection: "row",- alignItems: "center"- }}- >- <i- className="fa fa-certificate"- style={{- color: "white",- fontSize: "15px",- marginRight: "3px"- }}- aria-hidden="true"- ></i>- Certificate- </button>- )- }- </PDFDownloadLink>+ <CertificateComponent />)}<buttononClick={handleToPrint}@@ -518,42 +559,7 @@ function Header({) : isPdfRequestFiles ? (alreadySign ? (<div style={{ display: "flex", flexDirection: "row" }}>- {isCompleted.isCertificate && (- <PDFDownloadLink- style={{ textDecoration: "none" }}- document={<Certificate pdfData={pdfDetails} />}- fileName={`completion certificate-${- pdfDetails[0] && pdfDetails[0].Name- }.pdf`}- >- {({ blob, url, loading, error }) =>- loading ? (- "Loading document..."- ) : (- <button- type="button"- className="defaultBtn certificateBtn"- style={{- display: "flex",- flexDirection: "row",- alignItems: "center"- }}- >- <i- className="fa fa-certificate"- style={{- color: "white",- fontSize: "15px",- marginRight: "3px"- }}- aria-hidden="true"- ></i>- Certificate- </button>- )- }- </PDFDownloadLink>- )}+ {isCompleted.isCertificate && <CertificateComponent />}<buttononClick={handleToPrint}type="button"@@ -640,40 +646,7 @@ function Header({)) : pdfUrl || (documentStatus && documentStatus.isCompleted) ? (<div style={{ display: "flex", flexDirection: "row" }}>- <PDFDownloadLink- style={{ textDecoration: "none" }}- document={<Certificate pdfData={pdfDetails} />}- fileName={`completion certificate-${- pdfDetails[0] && pdfDetails[0].Name- }.pdf`}- >- {({ blob, url, loading, error }) =>- loading ? (- "Loading document..."- ) : (- <button- type="button"- style={{- display: "flex",- flexDirection: "row",- alignItems: "center"- }}- className="defaultBtn certificateBtn"- >- <i- className="fa fa-certificate"- style={{- color: "white",- fontSize: "15px",- marginRight: "3px"- }}- aria-hidden="true"- ></i>- Certificate- </button>- )- }- </PDFDownloadLink>+ <CertificateComponent /><buttononClick={handleToPrint}type="button"@@ -752,4 +725,4 @@ function Header({);}-export default Header;\ No newline at end of file+export default Header;diff --git a/microfrontends/SignDocuments/src/assests/open-sign-logo.png b/microfrontends/SignDocuments/src/assests/open-sign-logo.pngnew file mode 100644index 000000000..8db538124Binary files /dev/null and b/microfrontends/SignDocuments/src/assests/open-sign-logo.png differ