Skip to content

🔥 The free & Open Source DocuSign alternative

fix: merge conflict

prafull-opensignlabs70ae1e24fc1a
diff --cc apps/OpenSign/src/components/pdf/PdfHeader.js
index ad230f29d,075945526..419983798
--- a/apps/OpenSign/src/components/pdf/PdfHeader.js
+++ b/apps/OpenSign/src/components/pdf/PdfHeader.js
@@@ -255,7 -131,7 +131,9 @@@ function Header(
>
<DropdownMenu.Item
className="DropdownMenuItem"
- onClick={() => handleDownloadPdf()}
- onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
++ onClick={() =>
++ handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
++ }
>
<div
style={{
@@@ -274,7 -150,12 +152,12 @@@
{isCompleted && (
<DropdownMenu.Item
className="DropdownMenuItem"
- onClick={() => handleDownloadCertificate()}
+ onClick={() =>
+ handleDownloadCertificate(
+ pdfDetails,
- setIsCertificate
++ setIsDownloading
+ )
+ }
>
<div
style={{
@@@ -313,7 -194,7 +196,9 @@@
)}
<DropdownMenu.Item
className="DropdownMenuItem"
- onClick={handleToPrint}
- onClick={(e) => handleToPrint(e, pdfUrl)}
++ onClick={(e) =>
++ handleToPrint(e, pdfUrl, setIsDownloading)
++ }
>
<div
style={{
@@@ -395,7 -276,9 +280,13 @@@
>
<DropdownMenu.Item
className="flex flex-row justify-center items-center text-[13px] focus:outline-none cursor-pointer"
- onClick={() => handleDownloadPdf()}
+ onClick={() =>
- handleDownloadPdf(pdfDetails, pdfUrl)
++ handleDownloadPdf(
++ pdfDetails,
++ pdfUrl,
++ setIsDownloading
++ )
+ }
>
<i
className="fa fa-arrow-down mr-[5px]"
@@@ -482,7 -365,9 +373,9 @@@
{isCompleted && (
<button
type="button"
- onClick={() => handleDownloadCertificate()}
+ onClick={() =>
- handleDownloadCertificate(pdfDetails, setIsCertificate)
++ handleDownloadCertificate(pdfDetails, setIsDownloading)
+ }
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
>
<i
@@@ -494,7 -379,7 +387,7 @@@
)}
<button
- onClick={handleToPrint}
- onClick={(e) => handleToPrint(e, pdfUrl)}
++ onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
type="button"
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
>
@@@ -505,7 -390,7 +398,9 @@@
<button
type="button"
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
- onClick={() => handleDownloadPdf()}
- onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
++ onClick={() =>
++ handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
++ }
>
<i className="fa fa-download py-[3px]" aria-hidden="true"></i>
<span className="hidden lg:block ml-1">Download</span>
@@@ -554,7 -439,9 +449,13 @@@
>
<DropdownMenu.Item
className="flex flex-row justify-center items-center text-[13px] focus:outline-none cursor-pointer"
- onClick={() => handleDownloadPdf()}
+ onClick={() =>
- handleDownloadPdf(pdfDetails, pdfUrl)
++ handleDownloadPdf(
++ pdfDetails,
++ pdfUrl,
++ setIsDownloading
++ )
+ }
>
<i
className="fa fa-arrow-down mr-[5px]"
@@@ -574,7 -461,9 +475,9 @@@
{isCompleted && (
<button
type="button"
- onClick={() => handleDownloadCertificate()}
+ onClick={() =>
- handleDownloadCertificate(pdfDetails, setIsCertificate)
++ handleDownloadCertificate(pdfDetails, setIsDownloading)
+ }
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
>
<i
@@@ -585,7 -474,7 +488,7 @@@
</button>
)}
<button
- onClick={handleToPrint}
- onClick={(e) => handleToPrint(e, pdfUrl)}
++ onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
type="button"
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
>
@@@ -595,7 -484,7 +498,9 @@@
<button
type="button"
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
- onClick={() => handleDownloadPdf()}
- onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
++ onClick={() =>
++ handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
++ }
>
<i className="fa fa-download py-[3px]" aria-hidden="true"></i>
<span className="hidden lg:block ml-1">Download</span>
diff --cc apps/OpenSign/src/constant/Utils.js
index 9d310dd82,7cb9be16b..147d360d2
--- a/apps/OpenSign/src/constant/Utils.js
+++ b/apps/OpenSign/src/constant/Utils.js
@@@ -2030,8 -2033,124 +2033,134 @@@ export const handleSendOTP = async (ema
alert(error.message);
}
};
+ //handle download signed pdf
-export const handleDownloadPdf = async (pdfDetails, pdfUrl) => {
++export const handleDownloadPdf = async (
++ pdfDetails,
++ pdfUrl,
++ setIsDownloading
++) => {
+ const pdfName = pdfDetails[0] && pdfDetails[0].Name;
++ setIsDownloading("pdf");
+ try {
+ // const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
+ const axiosRes = await axios.post(
+ `${appInfo.baseUrl}/functions/getsignedurl`,
+ { url: pdfUrl },
+ {
+ headers: {
+ "content-type": "Application/json",
+ "X-Parse-Application-Id": appInfo.appId,
+ "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ }
+ }
+ );
+ const url = axiosRes.data.result;
+ saveAs(url, `${sanitizeFileName(pdfName)}_signed_by_OpenSignâ„¢.pdf`);
++ setIsDownloading("");
+ } catch (err) {
+ console.log("err in getsignedurl", err);
++ setIsDownloading("");
+ alert("something went wrong, please try again later.");
+ }
+ };
+ export const sanitizeFileName = (pdfName) => {
+ // Replace spaces with underscore
+ return pdfName.replace(/ /g, "_");
+ };
+ //function for print digital sign pdf
-export const handleToPrint = async (event, pdfUrl) => {
++export const handleToPrint = async (event, pdfUrl, setIsDownloading) => {
+ event.preventDefault();
-
++ setIsDownloading("pdf");
+ try {
+ // const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
+ const axiosRes = await axios.post(
+ `${appInfo.baseUrl}/functions/getsignedurl`,
+ { url: pdfUrl },
+ {
+ headers: {
+ "content-type": "Application/json",
+ "X-Parse-Application-Id": appInfo.appId,
+ "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ }
+ }
+ );
+ const url = axiosRes.data.result;
+ const pdf = await getBase64FromUrl(url);
+ 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");
++ setIsDownloading("");
+ } else {
+ printModule({ printable: pdf, type: "pdf", base64: true });
++ setIsDownloading("");
+ }
+ } catch (err) {
++ setIsDownloading("");
+ console.log("err in getsignedurl", err);
+ alert("something went wrong, please try again later.");
+ }
+ };
+
+ //handle download signed pdf
+ export const handleDownloadCertificate = async (
+ pdfDetails,
- setIsCertificate
++ setIsDownloading
+ ) => {
+ if (pdfDetails?.length > 0 && pdfDetails[0]?.CertificateUrl) {
+ try {
+ await fetch(pdfDetails[0] && pdfDetails[0]?.CertificateUrl);
+ const certificateUrl = pdfDetails[0] && pdfDetails[0]?.CertificateUrl;
+ saveAs(certificateUrl, `Certificate_signed_by_OpenSignâ„¢.pdf`);
+ } catch (err) {
+ console.log("err in download in certificate", err);
+ }
+ } else {
- setIsCertificate(true);
++ setIsDownloading("certificate");
+ try {
+ const data = {
+ docId: pdfDetails[0]?.objectId
+ };
+ const docDetails = await axios.post(
+ `${localStorage.getItem("baseUrl")}functions/getDocument`,
+ data,
+ {
+ headers: {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
+ sessionToken: localStorage.getItem("accesstoken")
+ }
+ }
+ );
+ if (docDetails.data && docDetails.data.result) {
+ const doc = docDetails.data.result;
+ if (doc?.CertificateUrl) {
+ await fetch(doc?.CertificateUrl);
+ const certificateUrl = doc?.CertificateUrl;
+ saveAs(certificateUrl, `Certificate_signed_by_OpenSignâ„¢.pdf`);
- setIsCertificate(false);
++ setIsDownloading("");
+ } else {
- setIsCertificate(true);
++ setIsDownloading("certificate");
+ }
+ }
+ } catch (err) {
+ console.log("err in download in certificate", err);
+ alert("something went wrong, please try again later.");
+ }
+ }
+ };
- export async function findContact(value) {
+export async function findContact(value) {
try {
const currentUser = Parse.User.current();
const contactbook = new Parse.Query("contracts_Contactbook");
diff --cc apps/OpenSign/src/pages/PdfRequestFiles.js
index 2b3a3f976,eeaf852a8..505b4b493
--- a/apps/OpenSign/src/pages/PdfRequestFiles.js
+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js
@@@ -92,6 -95,7 +95,7 @@@ function PdfRequestFiles()
const [expiredDate, setExpiredDate] = useState("");
const [signerUserId, setSignerUserId] = useState();
const [isDontShow, setIsDontShow] = useState(false);
- const [isCertificate, setIsCertificate] = useState(false);
++ const [isDownloading, setIsDownloading] = useState("");
const [defaultSignAlert, setDefaultSignAlert] = useState({
isShow: false,
alertMessage: ""
@@@ -1567,38 -1568,85 +1571,104 @@@
handleClose={() => {
setIsCompleted((prev) => ({ ...prev, isModal: false }));
}}
+ reduceWidth={!isCompleted?.message}
>
<div style={{ height: "100%", padding: 20 }}>
- <p>
- {" "}
- {isCompleted?.message ||
- "This document has been signed by all Signers."}
- </p>
-
+ {isCompleted?.message ? (
+ <p>{isCompleted?.message}</p>
+ ) : (
+ <div className="px-[15px]">
+ <span>
+ Congratulations! 🎉 This document has been
+ successfully signed by all participants!
+ </span>
+ </div>
+ )}
+ {!isCompleted?.message && (
+ <div className="flex mt-4 gap-1 px-[15px]">
+ <button
+ type="button"
+ onClick={() =>
+ handleDownloadCertificate(
+ pdfDetails,
- setIsCertificate
++ setIsDownloading
+ )
+ }
+ className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
+ >
+ <i
+ className="fa-solid fa-award py-[3px]"
+ aria-hidden="true"
+ ></i>
+ <span className="hidden lg:block ml-1">
+ Certificate
+ </span>
+ </button>
+ <button
- onClick={(e) => handleToPrint(e, pdfUrl)}
++ onClick={(e) =>
++ handleToPrint(e, pdfUrl, setIsDownloading)
++ }
+ type="button"
+ className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
+ >
+ <i
+ className="fa fa-print py-[3px]"
+ aria-hidden="true"
+ ></i>
+ <span className="hidden lg:block ml-1">Print</span>
+ </button>
+ <button
+ type="button"
+ className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
+ onClick={() =>
- handleDownloadPdf(pdfDetails, pdfUrl)
++ handleDownloadPdf(
++ pdfDetails,
++ pdfUrl,
++ setIsDownloading
++ )
+ }
+ >
+ <i
+ className="fa fa-download py-[3px]"
+ aria-hidden="true"
+ ></i>
+ <span className="hidden lg:block ml-1">
+ Download
+ </span>
+ </button>
+ </div>
+ )}
+ </div>
+ </ModalUi>
++ {isDownloading === "pdf" && (
++ <div className="fixed z-[1000] inset-0 flex justify-center items-center bg-black bg-opacity-30">
+ <div
- style={{
- height: "1px",
- backgroundColor: "#9f9f9f",
- width: "100%",
- marginTop: "15px",
- marginBottom: "15px"
- }}
++ style={{ fontSize: "45px", color: "#3dd3e0" }}
++ className="loader-37"
+ ></div>
- <button
- type="button"
- className="finishBtn cancelBtn"
- onClick={() => {
- setIsCompleted((prev) => ({
- ...prev,
- isModal: false
- }));
- }}
- >
- Close
- </button>
++ </div>
++ )}
+ <ModalUi
- isOpen={isCertificate}
- title={"Generating certificate"}
- handleClose={() => setIsCertificate(false)}
++ isOpen={isDownloading === "certificate"}
++ title={
++ isDownloading === "certificate"
++ ? "Generating certificate"
++ : "PDF Download"
++ }
++ handleClose={() => setIsDownloading("")}
+ >
+ <div className="p-3 md:p-5 text-[13px] md:text-base text-center">
++ {isDownloading === "certificate"}{" "}
+ <p>
+ Your completion certificate is being generated. Please
+ wait momentarily.
+ </p>
+ <p>
+ If the download doesn&apos;t start shortly, click the
+ button again.
+ </p>
</div>
</ModalUi>
-
{/* this component is used for signature pad modal */}
<SignPad
isSignPad={isSignPad}