diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js index e816f99d6..2d5bb3b2b 100644 --- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js +++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js @@ -989,6 +989,7 @@ function SignYourSelf() { currentSigner={true} alreadySign={pdfUrl ? true : false} isSignYourself={true} + setIsEmail={setIsEmail} /> {/* className="hidePdf" */} diff --git a/microfrontends/SignDocuments/src/Component/component/emailComponent.js b/microfrontends/SignDocuments/src/Component/component/emailComponent.js index cb67fd0b3..5854c8749 100644 --- a/microfrontends/SignDocuments/src/Component/component/emailComponent.js +++ b/microfrontends/SignDocuments/src/Component/component/emailComponent.js @@ -20,14 +20,14 @@ function EmailComponent({ pdfName, sender }) { - const [emailCount, setEmailCount] = useState([]); + const [emailList, setEmailList] = useState([]); const [emailValue, setEmailValue] = useState(); const [isLoading, setIsLoading] = useState(false); //function for send email const sendEmail = async () => { setIsLoading(true); let sendMail; - for (let i = 0; i < emailCount.length; i++) { + for (let i = 0; i < emailList.length; i++) { try { const imgPng = "https://qikinnovation.ams3.digitaloceanspaces.com/logo.png"; @@ -44,7 +44,7 @@ function EmailComponent({ let params = { pdfName: pdfName, url: pdfUrl, - recipient: emailCount[i], + recipient: emailList[i], subject: `${sender.name} has signed the doc - ${pdfName}`, from: sender.email, html: @@ -67,11 +67,14 @@ function EmailComponent({ } if (sendMail.data.result.status === "success") { - setIsEmail(false); setSuccessEmail(true); setTimeout(() => { setSuccessEmail(false); - }, 3000); + setIsEmail(false); + setEmailValue(""); + setEmailList([]); + }, 1500); + setIsLoading(false); } else if (sendMail.data.result.status === "error") { setIsLoading(false); @@ -81,10 +84,11 @@ function EmailComponent({ alert("Something went wrong!"); } }; + //function for remove email const removeChip = (index) => { - const updateEmailCount = emailCount.filter((data, key) => key !== index); - setEmailCount(updateEmailCount); + const updateEmailCount = emailList.filter((data, key) => key !== index); + setEmailList(updateEmailCount); }; //function for get email value const handleEmailValue = (e) => { @@ -95,10 +99,10 @@ function EmailComponent({ //function for save email in array after press enter const handleEnterPress = (e) => { if (e.key === "Enter" && emailValue) { - setEmailCount((prev) => [...prev, emailValue]); + setEmailList((prev) => [...prev, emailValue]); setEmailValue(""); } else if (e === "add" && emailValue) { - setEmailCount((prev) => [...prev, emailValue]); + setEmailList((prev) => [...prev, emailValue]); setEmailValue(""); } }; @@ -249,7 +253,7 @@ function EmailComponent({ > Recipients added here will get a copy of the signed document.
- {emailCount.length > 0 ? ( + {emailList.length > 0 ? ( <>