add delivered page
This commit is contained in:
parent
590ad6d880
commit
be1cfbb166
|
@ -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";
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
<div className="container shadow-sm mx-auto ">
|
||||
{loading ?
|
||||
<>
|
||||
|
||||
<div className="col-lg-6 col-md-6 col-sm-12 mx-auto">
|
||||
<h3>Delivered emails</h3>
|
||||
{delivered_emails}
|
||||
</div>
|
||||
|
||||
<div className="col-lg-6 col-md-6 col-sm-12 mx-auto">
|
||||
<h3>Bounced Emails</h3>
|
||||
{bounced_emails}
|
||||
</div>
|
||||
<button className="btn btn-secondary my-5" onClick={() => window.location.reload(false)} >
|
||||
send more emails!
|
||||
</button>
|
||||
</>
|
||||
:
|
||||
|
||||
<>
|
||||
<h1 className="text-center font-weight-bold">
|
||||
Email Template to Recipients
|
||||
</h1>
|
||||
|
@ -149,7 +181,12 @@ const EmailTemplate = () => {
|
|||
Submit!
|
||||
</button>
|
||||
</form>
|
||||
{bounced_emails}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -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!
|
Loading…
Reference in New Issue