Skip to content

Commit f52c6e2

Browse files
authored
Merge pull request #784 from OpenSignLabs/feat_bulksend
2 parents 6875135 + 70ae1e2 commit f52c6e2

File tree

8 files changed

+176
-45
lines changed

8 files changed

+176
-45
lines changed

apps/OpenSign/src/components/pdf/PdfHeader.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Header({
4040
signerPos && signerPos?.filter((data) => data.Role !== "prefill");
4141
const isMobile = window.innerWidth < 767;
4242
const navigate = useNavigate();
43-
const [isCertificate, setIsCertificate] = useState(false);
43+
const [isDownloading, setIsDownloading] = useState("");
4444
const isGuestSigner = localStorage.getItem("isGuestSigner");
4545
//for go to previous page
4646
function previousPage() {
@@ -131,7 +131,9 @@ function Header({
131131
>
132132
<DropdownMenu.Item
133133
className="DropdownMenuItem"
134-
onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
134+
onClick={() =>
135+
handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
136+
}
135137
>
136138
<div
137139
style={{
@@ -153,7 +155,7 @@ function Header({
153155
onClick={() =>
154156
handleDownloadCertificate(
155157
pdfDetails,
156-
setIsCertificate
158+
setIsDownloading
157159
)
158160
}
159161
>
@@ -194,7 +196,9 @@ function Header({
194196
)}
195197
<DropdownMenu.Item
196198
className="DropdownMenuItem"
197-
onClick={(e) => handleToPrint(e, pdfUrl)}
199+
onClick={(e) =>
200+
handleToPrint(e, pdfUrl, setIsDownloading)
201+
}
198202
>
199203
<div
200204
style={{
@@ -277,7 +281,11 @@ function Header({
277281
<DropdownMenu.Item
278282
className="flex flex-row justify-center items-center text-[13px] focus:outline-none cursor-pointer"
279283
onClick={() =>
280-
handleDownloadPdf(pdfDetails, pdfUrl)
284+
handleDownloadPdf(
285+
pdfDetails,
286+
pdfUrl,
287+
setIsDownloading
288+
)
281289
}
282290
>
283291
<i
@@ -366,7 +374,7 @@ function Header({
366374
<button
367375
type="button"
368376
onClick={() =>
369-
handleDownloadCertificate(pdfDetails, setIsCertificate)
377+
handleDownloadCertificate(pdfDetails, setIsDownloading)
370378
}
371379
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
372380
>
@@ -379,7 +387,7 @@ function Header({
379387
)}
380388

381389
<button
382-
onClick={(e) => handleToPrint(e, pdfUrl)}
390+
onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
383391
type="button"
384392
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
385393
>
@@ -390,7 +398,9 @@ function Header({
390398
<button
391399
type="button"
392400
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
393-
onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
401+
onClick={() =>
402+
handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
403+
}
394404
>
395405
<i className="fa fa-download py-[3px]" aria-hidden="true"></i>
396406
<span className="hidden lg:block ml-1">Download</span>
@@ -440,7 +450,11 @@ function Header({
440450
<DropdownMenu.Item
441451
className="flex flex-row justify-center items-center text-[13px] focus:outline-none cursor-pointer"
442452
onClick={() =>
443-
handleDownloadPdf(pdfDetails, pdfUrl)
453+
handleDownloadPdf(
454+
pdfDetails,
455+
pdfUrl,
456+
setIsDownloading
457+
)
444458
}
445459
>
446460
<i
@@ -462,7 +476,7 @@ function Header({
462476
<button
463477
type="button"
464478
onClick={() =>
465-
handleDownloadCertificate(pdfDetails, setIsCertificate)
479+
handleDownloadCertificate(pdfDetails, setIsDownloading)
466480
}
467481
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
468482
>
@@ -474,7 +488,7 @@ function Header({
474488
</button>
475489
)}
476490
<button
477-
onClick={(e) => handleToPrint(e, pdfUrl)}
491+
onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
478492
type="button"
479493
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
480494
>
@@ -484,7 +498,9 @@ function Header({
484498
<button
485499
type="button"
486500
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
487-
onClick={() => handleDownloadPdf(pdfDetails, pdfUrl)}
501+
onClick={() =>
502+
handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)
503+
}
488504
>
489505
<i className="fa fa-download py-[3px]" aria-hidden="true"></i>
490506
<span className="hidden lg:block ml-1">Download</span>
@@ -524,12 +540,25 @@ function Header({
524540
)}
525541
</div>
526542
)}
543+
{isDownloading === "pdf" && (
544+
<div className="fixed z-[200] inset-0 flex justify-center items-center bg-black bg-opacity-30">
545+
<div
546+
style={{ fontSize: "45px", color: "#3dd3e0" }}
547+
className="loader-37"
548+
></div>
549+
</div>
550+
)}
527551
<ModalUi
528-
isOpen={isCertificate}
529-
title={"Generating certificate"}
530-
handleClose={() => setIsCertificate(false)}
552+
isOpen={isDownloading === "certificate"}
553+
title={
554+
isDownloading === "certificate"
555+
? "Generating certificate"
556+
: "PDF Download"
557+
}
558+
handleClose={() => setIsDownloading("")}
531559
>
532560
<div className="p-3 md:p-5 text-[13px] md:text-base text-center">
561+
{isDownloading === "certificate"}{" "}
533562
<p>
534563
Your completion certificate is being generated. Please wait
535564
momentarily.

apps/OpenSign/src/constant/Utils.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,8 +2034,13 @@ export const handleSendOTP = async (email) => {
20342034
}
20352035
};
20362036
//handle download signed pdf
2037-
export const handleDownloadPdf = async (pdfDetails, pdfUrl) => {
2037+
export const handleDownloadPdf = async (
2038+
pdfDetails,
2039+
pdfUrl,
2040+
setIsDownloading
2041+
) => {
20382042
const pdfName = pdfDetails[0] && pdfDetails[0].Name;
2043+
setIsDownloading("pdf");
20392044
try {
20402045
// const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
20412046
const axiosRes = await axios.post(
@@ -2051,8 +2056,10 @@ export const handleDownloadPdf = async (pdfDetails, pdfUrl) => {
20512056
);
20522057
const url = axiosRes.data.result;
20532058
saveAs(url, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`);
2059+
setIsDownloading("");
20542060
} catch (err) {
20552061
console.log("err in getsignedurl", err);
2062+
setIsDownloading("");
20562063
alert("something went wrong, please try again later.");
20572064
}
20582065
};
@@ -2062,9 +2069,9 @@ export const sanitizeFileName = (pdfName) => {
20622069
return pdfName.replace(/ /g, "_");
20632070
};
20642071
//function for print digital sign pdf
2065-
export const handleToPrint = async (event, pdfUrl) => {
2072+
export const handleToPrint = async (event, pdfUrl, setIsDownloading) => {
20662073
event.preventDefault();
2067-
2074+
setIsDownloading("pdf");
20682075
try {
20692076
// const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
20702077
const axiosRes = await axios.post(
@@ -2094,10 +2101,13 @@ export const handleToPrint = async (event, pdfUrl) => {
20942101
const blob = new Blob([byteArray], { type: "application/pdf" });
20952102
const blobUrl = URL.createObjectURL(blob);
20962103
window.open(blobUrl, "_blank");
2104+
setIsDownloading("");
20972105
} else {
20982106
printModule({ printable: pdf, type: "pdf", base64: true });
2107+
setIsDownloading("");
20992108
}
21002109
} catch (err) {
2110+
setIsDownloading("");
21012111
console.log("err in getsignedurl", err);
21022112
alert("something went wrong, please try again later.");
21032113
}
@@ -2106,7 +2116,7 @@ export const handleToPrint = async (event, pdfUrl) => {
21062116
//handle download signed pdf
21072117
export const handleDownloadCertificate = async (
21082118
pdfDetails,
2109-
setIsCertificate
2119+
setIsDownloading
21102120
) => {
21112121
if (pdfDetails?.length > 0 && pdfDetails[0]?.CertificateUrl) {
21122122
try {
@@ -2117,7 +2127,7 @@ export const handleDownloadCertificate = async (
21172127
console.log("err in download in certificate", err);
21182128
}
21192129
} else {
2120-
setIsCertificate(true);
2130+
setIsDownloading("certificate");
21212131
try {
21222132
const data = {
21232133
docId: pdfDetails[0]?.objectId
@@ -2139,9 +2149,9 @@ export const handleDownloadCertificate = async (
21392149
await fetch(doc?.CertificateUrl);
21402150
const certificateUrl = doc?.CertificateUrl;
21412151
saveAs(certificateUrl, `Certificate_signed_by_OpenSign™.pdf`);
2142-
setIsCertificate(false);
2152+
setIsDownloading("");
21432153
} else {
2144-
setIsCertificate(true);
2154+
setIsDownloading("certificate");
21452155
}
21462156
}
21472157
} catch (err) {
@@ -2150,7 +2160,7 @@ export const handleDownloadCertificate = async (
21502160
}
21512161
}
21522162
};
2153-
export async function findContact(value) {
2163+
export async function findContact(value) {
21542164
try {
21552165
const currentUser = Parse.User.current();
21562166
const contactbook = new Parse.Query("contracts_Contactbook");

apps/OpenSign/src/json/ReportJson.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export default function reportJson(id) {
33
const head = ["Sr.No", "Title", "Note", "Folder", "File", "Owner", "Signers"];
44
const contactbook = ["Sr.No", "Title", "Email", "Phone"];
55
const dashboardReportHead = ["Title", "File", "Owner", "Signers"];
6-
const templateReport = ["Sr.No", "Title", "File", "Owner", "Signers"];
6+
const templateReport = ["Sr.No", "Title", "File", "Owner", "Roles"];
77
switch (id) {
88
// draft documents report
99
case "ByHuevtCFY":

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function PdfRequestFiles() {
9595
const [expiredDate, setExpiredDate] = useState("");
9696
const [signerUserId, setSignerUserId] = useState();
9797
const [isDontShow, setIsDontShow] = useState(false);
98-
const [isCertificate, setIsCertificate] = useState(false);
98+
const [isDownloading, setIsDownloading] = useState("");
9999
const [defaultSignAlert, setDefaultSignAlert] = useState({
100100
isShow: false,
101101
alertMessage: ""
@@ -787,7 +787,10 @@ function PdfRequestFiles() {
787787
(x) => x.Email === jsonSender.email
788788
);
789789
const newIndex = index + 1;
790-
const user = pdfDetails?.[0].Signers[newIndex];
790+
const usermail = {
791+
Email: pdfDetails?.[0]?.Placeholders[newIndex]?.email || ""
792+
};
793+
const user = usermail || pdfDetails?.[0]?.Signers[newIndex];
791794
if (sendmail !== "false" && sendInOrder) {
792795
const requestBody = pdfDetails?.[0]?.RequestBody;
793796
const requestSubject = pdfDetails?.[0]?.RequestSubject;
@@ -1588,7 +1591,7 @@ function PdfRequestFiles() {
15881591
onClick={() =>
15891592
handleDownloadCertificate(
15901593
pdfDetails,
1591-
setIsCertificate
1594+
setIsDownloading
15921595
)
15931596
}
15941597
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#08bc66]"
@@ -1602,7 +1605,9 @@ function PdfRequestFiles() {
16021605
</span>
16031606
</button>
16041607
<button
1605-
onClick={(e) => handleToPrint(e, pdfUrl)}
1608+
onClick={(e) =>
1609+
handleToPrint(e, pdfUrl, setIsDownloading)
1610+
}
16061611
type="button"
16071612
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#188ae2]"
16081613
>
@@ -1616,7 +1621,11 @@ function PdfRequestFiles() {
16161621
type="button"
16171622
className="flex flex-row items-center shadow rounded-[3px] py-[3px] px-[11px] text-white font-[500] text-[13px] mr-[5px] bg-[#f14343]"
16181623
onClick={() =>
1619-
handleDownloadPdf(pdfDetails, pdfUrl)
1624+
handleDownloadPdf(
1625+
pdfDetails,
1626+
pdfUrl,
1627+
setIsDownloading
1628+
)
16201629
}
16211630
>
16221631
<i
@@ -1631,12 +1640,25 @@ function PdfRequestFiles() {
16311640
)}
16321641
</div>
16331642
</ModalUi>
1643+
{isDownloading === "pdf" && (
1644+
<div className="fixed z-[1000] inset-0 flex justify-center items-center bg-black bg-opacity-30">
1645+
<div
1646+
style={{ fontSize: "45px", color: "#3dd3e0" }}
1647+
className="loader-37"
1648+
></div>
1649+
</div>
1650+
)}
16341651
<ModalUi
1635-
isOpen={isCertificate}
1636-
title={"Generating certificate"}
1637-
handleClose={() => setIsCertificate(false)}
1652+
isOpen={isDownloading === "certificate"}
1653+
title={
1654+
isDownloading === "certificate"
1655+
? "Generating certificate"
1656+
: "PDF Download"
1657+
}
1658+
handleClose={() => setIsDownloading("")}
16381659
>
16391660
<div className="p-3 md:p-5 text-[13px] md:text-base text-center">
1661+
{isDownloading === "certificate"}{" "}
16401662
<p>
16411663
Your completion certificate is being generated. Please
16421664
wait momentarily.

0 commit comments

Comments
 (0)