Skip to content

Commit b6ce005

Browse files
authored
Merge pull request #257 from OpenSignLabs/send-mail
2 parents d17951a + 7495955 commit b6ce005

File tree

6 files changed

+113
-49
lines changed

6 files changed

+113
-49
lines changed

microfrontends/SignDocuments/src/Component/SignYourselfPdf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ function SignYourSelf() {
989989
currentSigner={true}
990990
alreadySign={pdfUrl ? true : false}
991991
isSignYourself={true}
992+
setIsEmail={setIsEmail}
992993
/>
993994

994995
{/* className="hidePdf" */}

microfrontends/SignDocuments/src/Component/component/emailComponent.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ function EmailComponent({
2020
pdfName,
2121
sender
2222
}) {
23-
const [emailCount, setEmailCount] = useState([]);
23+
const [emailList, setEmailList] = useState([]);
2424
const [emailValue, setEmailValue] = useState();
2525
const [isLoading, setIsLoading] = useState(false);
2626
//function for send email
2727
const sendEmail = async () => {
2828
setIsLoading(true);
2929
let sendMail;
30-
for (let i = 0; i < emailCount.length; i++) {
30+
for (let i = 0; i < emailList.length; i++) {
3131
try {
3232
const imgPng =
3333
"https://qikinnovation.ams3.digitaloceanspaces.com/logo.png";
@@ -44,7 +44,7 @@ function EmailComponent({
4444
let params = {
4545
pdfName: pdfName,
4646
url: pdfUrl,
47-
recipient: emailCount[i],
47+
recipient: emailList[i],
4848
subject: `${sender.name} has signed the doc - ${pdfName}`,
4949
from: sender.email,
5050
html:
@@ -67,11 +67,14 @@ function EmailComponent({
6767
}
6868

6969
if (sendMail.data.result.status === "success") {
70-
setIsEmail(false);
7170
setSuccessEmail(true);
7271
setTimeout(() => {
7372
setSuccessEmail(false);
74-
}, 3000);
73+
setIsEmail(false);
74+
setEmailValue("");
75+
setEmailList([]);
76+
}, 1500);
77+
7578
setIsLoading(false);
7679
} else if (sendMail.data.result.status === "error") {
7780
setIsLoading(false);
@@ -81,10 +84,11 @@ function EmailComponent({
8184
alert("Something went wrong!");
8285
}
8386
};
87+
8488
//function for remove email
8589
const removeChip = (index) => {
86-
const updateEmailCount = emailCount.filter((data, key) => key !== index);
87-
setEmailCount(updateEmailCount);
90+
const updateEmailCount = emailList.filter((data, key) => key !== index);
91+
setEmailList(updateEmailCount);
8892
};
8993
//function for get email value
9094
const handleEmailValue = (e) => {
@@ -95,10 +99,10 @@ function EmailComponent({
9599
//function for save email in array after press enter
96100
const handleEnterPress = (e) => {
97101
if (e.key === "Enter" && emailValue) {
98-
setEmailCount((prev) => [...prev, emailValue]);
102+
setEmailList((prev) => [...prev, emailValue]);
99103
setEmailValue("");
100104
} else if (e === "add" && emailValue) {
101-
setEmailCount((prev) => [...prev, emailValue]);
105+
setEmailList((prev) => [...prev, emailValue]);
102106
setEmailValue("");
103107
}
104108
};
@@ -249,7 +253,7 @@ function EmailComponent({
249253
>
250254
Recipients added here will get a copy of the signed document.
251255
</p>
252-
{emailCount.length > 0 ? (
256+
{emailList.length > 0 ? (
253257
<>
254258
<div className="addEmail">
255259
<div
@@ -260,7 +264,7 @@ function EmailComponent({
260264
flexWrap: "wrap"
261265
}}
262266
>
263-
{emailCount.map((data, ind) => {
267+
{emailList.map((data, ind) => {
264268
return (
265269
<div
266270
className="emailChip"
@@ -293,7 +297,7 @@ function EmailComponent({
293297
);
294298
})}
295299
</div>
296-
{emailCount.length <= 9 && (
300+
{emailList.length <= 9 && (
297301
<input
298302
type="text"
299303
value={emailValue}
@@ -363,18 +367,22 @@ function EmailComponent({
363367
}}
364368
type="button"
365369
className="finishBtn"
366-
onClick={() => setIsEmail(false)}
370+
onClick={() => {
371+
setIsEmail(false);
372+
setEmailValue("");
373+
setEmailList([]);
374+
}}
367375
>
368376
Close
369377
</button>
370378
<button
371-
disabled={emailCount.length === 0 && true}
379+
disabled={emailList.length === 0 && true}
372380
style={{
373381
background: themeColor(),
374382
color: "white"
375383
}}
376384
type="button"
377-
className={emailCount.length === 0 ? "defaultBtn" : "finishBtn"}
385+
className={emailList.length === 0 ? "defaultBtn" : "finishBtn"}
378386
onClick={() => sendEmail()}
379387
>
380388
Send
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from "react";
2+
import "../../css/signature.css";
3+
4+
function EmailToast({ isShow }) {
5+
return (
6+
<>
7+
{isShow && (
8+
<div style={{ display: "flex", justifyContent: "center" }}>
9+
<div
10+
className="alert alert-success successBox"
11+
style={{ zIndex: "1051" }}
12+
>
13+
Email sent successfully!
14+
</div>
15+
</div>
16+
)}
17+
</>
18+
);
19+
}
20+
21+
export default EmailToast;

microfrontends/SignDocuments/src/Component/component/header.js

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function Header({
3333
currentSigner,
3434
dataTut4,
3535
alreadySign,
36-
isSignYourself
36+
isSignYourself,
37+
setIsEmail
3738
}) {
3839
const isMobile = window.innerWidth < 767;
3940
const navigate = useNavigate();
@@ -329,9 +330,29 @@ function Header({
329330
</DropdownMenu.Item>
330331
) : (
331332
isSignYourself && (
332-
<DropdownMenu.Item className="DropdownMenuItem">
333-
<CertificateDropDown />
334-
</DropdownMenu.Item>
333+
<>
334+
<DropdownMenu.Item className="DropdownMenuItem">
335+
<CertificateDropDown />
336+
</DropdownMenu.Item>
337+
<DropdownMenu.Item
338+
className="DropdownMenuItem"
339+
onClick={() => setIsEmail(true)}
340+
>
341+
<div
342+
style={{
343+
display: "flex",
344+
flexDirection: "row"
345+
}}
346+
>
347+
<i
348+
class="fa fa-envelope"
349+
style={{ marginRight: "2px" }}
350+
aria-hidden="true"
351+
></i>
352+
Mail
353+
</div>
354+
</DropdownMenu.Item>
355+
</>
335356
)
336357
)}
337358
<DropdownMenu.Item
@@ -690,6 +711,28 @@ function Header({
690711
></i>
691712
Download
692713
</button>
714+
<button
715+
type="button"
716+
className="defaultBtn mailBtn"
717+
style={{
718+
display: "flex",
719+
flexDirection: "row",
720+
alignItems: "center",
721+
marginLeft: "10px"
722+
}}
723+
onClick={() => setIsEmail(true)}
724+
>
725+
<i
726+
class="fa fa-envelope"
727+
style={{
728+
color: "white",
729+
fontSize: "15px",
730+
marginRight: "3px"
731+
}}
732+
aria-hidden="true"
733+
></i>
734+
Mail
735+
</button>
693736
</div>
694737
) : (
695738
<div>

microfrontends/SignDocuments/src/Component/component/renderPdf.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from "react";
22
import RSC from "react-scrollbars-custom";
3-
import Toast from "react-bootstrap/Toast";
43
import { Rnd } from "react-rnd";
54
import { themeColor } from "../../utils/ThemeColor/backColor";
65
import { Document, Page, pdfjs } from "react-pdf";
6+
import EmailToast from "./emailToast";
77

88
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
99

@@ -274,20 +274,7 @@ function RenderPdf({
274274
ref={drop}
275275
id="container"
276276
>
277-
<div className="d-flex justify-content-center">
278-
<Toast
279-
show={successEmail}
280-
delay={3000}
281-
autohide
282-
className="d-inline-block m-1"
283-
bg="success"
284-
style={{ background: "#348545" }}
285-
>
286-
<Toast.Body className={"text-white"}>
287-
Email sent successful!
288-
</Toast.Body>
289-
</Toast>
290-
</div>
277+
<EmailToast isShow={successEmail} />
291278
{pdfLoadFail.status &&
292279
(recipient
293280
? !pdfUrl &&
@@ -825,20 +812,7 @@ function RenderPdf({
825812
ref={drop}
826813
id="container"
827814
>
828-
<div className="d-flex justify-content-center">
829-
<Toast
830-
show={successEmail}
831-
delay={3000}
832-
autohide
833-
className="d-inline-block m-1"
834-
bg="success"
835-
style={{ background: "#348545" }}
836-
>
837-
<Toast.Body className={"text-white"}>
838-
Email sent successful!
839-
</Toast.Body>
840-
</Toast>
841-
</div>
815+
<EmailToast isShow={successEmail} />
842816
{pdfLoadFail.status &&
843817
(recipient
844818
? !pdfUrl &&

microfrontends/SignDocuments/src/css/signature.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,24 @@
88
.penContainer {
99
width: 460px;
1010
}
11-
11+
.mailBtn{
12+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.18);
13+
padding: 3px 15px !important;
14+
background-color: rgb(79 190 241);
15+
border: none !important;
16+
color: white !important;
17+
}
18+
.mailBtn:hover {
19+
box-shadow: 0 2px 4px rgba(154, 36, 36, 0.1), 0 2px 4px rgba(0, 0, 0, 0.18);
20+
}
21+
.emailToast{
22+
position: absolute;
23+
z-index: 10;
24+
background: #aeedae;
25+
padding: 0 3px 3px 3px;
26+
margin: 2px;
27+
border-radius: 2px;
28+
}
1229
.signatureBtn {
1330
border: 1.5px solid #47a3ad;
1431
margin-bottom: 10px;

0 commit comments

Comments
 (0)