From be1cfbb166141796c4688de60dca11b411d1ba9c Mon Sep 17 00:00:00 2001 From: Priyatham Sai Chand Date: Sat, 6 Nov 2021 12:05:18 +0530 Subject: [PATCH] add delivered page --- src/App.js | 1 - src/BulkEmail.js | 75 ++++++++++++++++++++++++++++++++++++------------ texput.log | 21 ++++++++++++++ 3 files changed, 77 insertions(+), 20 deletions(-) create mode 100644 texput.log diff --git a/src/App.js b/src/App.js index a8c1730..f2d1cb0 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,3 @@ -import logo from './logo.svg'; import './App.css'; import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import ReactNotification from "react-notifications-component"; diff --git a/src/BulkEmail.js b/src/BulkEmail.js index ce8eb8d..769d60d 100644 --- a/src/BulkEmail.js +++ b/src/BulkEmail.js @@ -1,15 +1,15 @@ import React, { useState, useEffect } from "react"; import { store } from "react-notifications-component"; -import axios from "axios"; const EmailTemplate = () => { const [email, setEmail] = useState([]); const [name, setName] = useState([]); const [html, setHtml] = useState(""); + const [loading, setLoading] = useState(false); const [subject, setSubject] = useState(""); const [sender_email, setSender_Email] = useState(""); - const [webinar_link, setWebinarLink] = useState(""); - + const [bounced_emails, setBouncedEmails] = useState([]); + const [delivered_emails, setDeliveredEmails] = useState([]); const notifyPopup = (title,message,type) => { store.addNotification({ title:title , @@ -27,24 +27,18 @@ const EmailTemplate = () => { }); }; + var emailarray = email.toString().split(","); async function handleSubmit(e) { e.preventDefault(); - var emailarray = email.toString().split(","); emailarray = emailarray.map(value => value.trim()) - if (emailarray == "") { notifyPopup("error","emails empty","danger"); } + if (!email.length) { notifyPopup("error","emails empty","danger"); return;} var namearray = name.toString().split(","); namearray = namearray.map(value => value.trim()) - if (namearray == "") { notifyPopup("error","names empty","danger"); } - if (subject == "") { notifyPopup("error","subject empty","danger"); } - if (html == "") { notifyPopup("error","html empty","danger"); } - if (sender_email == "") { notifyPopup("error","sender email empty","danger"); } - - console.log("emails "+emailarray) - console.log("names "+namearray) - console.log("html "+typeof(html)) - console.log("subject "+typeof( subject )) - console.log("sender" + typeof(sender_email)); - fetch("https://slb37ny1bh.execute-api.ap-south-1.amazonaws.com/prod/email_batcher", { + if (subject === "") { notifyPopup("error","subject empty","danger"); return;} + if (html === "") { notifyPopup("error","html empty","danger"); return;} + if (sender_email === "") { notifyPopup("error", "sender email empty", "danger"); return; } + //setBouncedEmails([]) + await fetch("https://slb37ny1bh.execute-api.ap-south-1.amazonaws.com/prod/email_batcher", { method: "post", body: JSON.stringify({ "email": emailarray, @@ -57,14 +51,52 @@ const EmailTemplate = () => { .then((res) => res.json()) .then((result) => { console.log(result); - notifyPopup("Success",result.toString(),"success"); - }); - + result.forEach((value, index) => { + setBouncedEmails(oldArray => [...oldArray, value.email.slice(2, -2).concat(',')]); + }); + }) + //var common = emailarray.filter(x => bouncedarray.indexOf(x) !== -1) + setLoading(true); } + useEffect(() => { + + var bouncedarray = bounced_emails.toString().split(',') + bouncedarray = bouncedarray.map(value => value.trim()) + console.log("bounce array ", bouncedarray) + var common = emailarray.filter(x => !bouncedarray.includes(x)) + console.log("common array ", common) + setDeliveredEmails([]) + common.forEach((value, index) => { + setDeliveredEmails(oldArray => [...oldArray,value.concat(',')] ); + }); + },[bounced_emails]) + useEffect(() => { + + console.log("delivered ", delivered_emails ) + },[delivered_emails]) return ( <>
+ {loading ? + <> + +
+

Delivered emails

+ {delivered_emails} +
+ +
+

Bounced Emails

+ {bounced_emails} +
+ + + : + + <>

Email Template to Recipients

@@ -149,7 +181,12 @@ const EmailTemplate = () => { Submit! + {bounced_emails}
+ + } + + ); diff --git a/texput.log b/texput.log new file mode 100644 index 0000000..91d84d9 --- /dev/null +++ b/texput.log @@ -0,0 +1,21 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/W32TeX) (preloaded format=pdflatex 2021.8.31) 28 OCT 2021 00:14 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**design_meth.tex + +! Emergency stop. +<*> design_meth.tex + +End of file on the terminal! + + +Here is how much of TeX's memory you used: + 3 strings out of 478599 + 114 string characters out of 5858101 + 290599 words of memory out of 5000000 + 17987 multiletter control sequences out of 15000+600000 + 403430 words of font info for 27 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s +! ==> Fatal error occurred, no output PDF file produced!