MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / EmailComponent

Function EmailComponent

apps/OpenSign/src/components/pdf/EmailComponent.jsx:13–227  ·  view source on GitHub ↗
({
  isEmail,
  setIsEmail,
  setSuccessEmail,
  pdfDetails,
  setIsAlert,
  setIsDownloadModal
})

Source from the content-addressed store, hash-verified

11import Parse from "parse";
12
13function EmailComponent({
14 isEmail,
15 setIsEmail,
16 setSuccessEmail,
17 pdfDetails,
18 setIsAlert,
19 setIsDownloadModal
20}) {
21 const { t } = useTranslation();
22 const [emailList, setEmailList] = useState([]);
23 const [emailValue, setEmailValue] = useState("");
24 const [isLoading, setIsLoading] = useState(false);
25 const [emailErr, setEmailErr] = useState(false);
26 const [isDownloading, setIsDownloading] = useState("");
27 const isAndroid = /Android/i.test(navigator.userAgent);
28
29 //function for send email
30 const sendEmail = async () => {
31 setIsLoading(true);
32 const params = { docId: pdfDetails?.[0]?.objectId, recipients: emailList };
33 const sendmail = await Parse.Cloud.run("forwarddoc", params);
34 if (sendmail?.status === "success") {
35 setSuccessEmail(true);
36 setIsEmail(false);
37 setTimeout(() => {
38 setSuccessEmail(false);
39 setEmailValue("");
40 setEmailList([]);
41 }, 1500);
42 setIsLoading(false);
43 }
44 else {
45 setIsLoading(false);
46 setIsEmail(false);
47 setIsAlert({
48 isShow: true,
49 alertMessage: t("something-went-wrong-mssg")
50 });
51 setEmailValue("");
52 setEmailList([]);
53 }
54 };
55
56 //function for remove email
57 const removeChip = (index) => {
58 const updateEmailCount = emailList.filter((data, key) => key !== index);
59 setEmailList(updateEmailCount);
60 };
61 //function for get email value
62 const handleEmailValue = (e) => {
63 const value = e.target.value?.toLowerCase()?.replace(/\s/g, "");
64 setEmailErr(false);
65 setEmailValue(value);
66 };
67
68 //function for save email in array after press enter
69 const handleEnterPress = (e) => {
70 const pattern = emailRegex;

Callers

nothing calls this directly

Calls 5

handleToPrintFunction · 0.90
removeChipFunction · 0.85
sendEmailFunction · 0.85
handleCloseFunction · 0.70
handleEnterPressFunction · 0.70

Tested by

no test coverage detected