connect api gateway
This commit is contained in:
parent
317b991590
commit
200a07d977
|
@ -2,11 +2,12 @@ import React, { useState, useEffect } from "react";
|
||||||
import { store } from "react-notifications-component";
|
import { store } from "react-notifications-component";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
const EmailTemplate = () => {
|
const EmailTemplate = () => {
|
||||||
|
|
||||||
const [email, setEmail] = useState([]);
|
const [email, setEmail] = useState([]);
|
||||||
const [name, setName] = useState([]);
|
const [name, setName] = useState([]);
|
||||||
const [html, setHtml] = useState("");
|
const [html, setHtml] = useState("");
|
||||||
const [subject, setSubject] = useState("");
|
const [subject, setSubject] = useState("");
|
||||||
const [company_email, setCompany_Email] = useState("");
|
const [sender_email, setSender_Email] = useState("");
|
||||||
const [webinar_link, setWebinarLink] = useState("");
|
const [webinar_link, setWebinarLink] = useState("");
|
||||||
|
|
||||||
const notifyPopup = (title,message,type) => {
|
const notifyPopup = (title,message,type) => {
|
||||||
|
@ -28,29 +29,34 @@ const EmailTemplate = () => {
|
||||||
|
|
||||||
async function handleSubmit(e) {
|
async function handleSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var array = email.toString().split(",");
|
var emailarray = email.toString().split(",");
|
||||||
if (array == "") { notifyPopup("error","emails empty","danger"); }
|
emailarray = emailarray.map(value => value.trim())
|
||||||
var nameArray = name.toString().split(",");
|
if (emailarray == "") { notifyPopup("error","emails empty","danger"); }
|
||||||
if (nameArray == "") { notifyPopup("error","names empty","danger"); }
|
var namearray = name.toString().split(",");
|
||||||
|
namearray = namearray.map(value => value.trim())
|
||||||
console.log(array);
|
if (namearray == "") { notifyPopup("error","names empty","danger"); }
|
||||||
console.log(company_email);
|
if (subject == "") { notifyPopup("error","subject empty","danger"); }
|
||||||
fetch("", {
|
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", {
|
||||||
method: "post",
|
method: "post",
|
||||||
headers: { "content-type": "application/json", "Access-Control-Allow-Origin":"*",},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
emailArray: array,
|
"email": emailarray,
|
||||||
nameArray,
|
"name": namearray,
|
||||||
template: html,
|
"html": html,
|
||||||
subject,
|
"subject": subject,
|
||||||
webinar_link,
|
"senderemail": sender_email
|
||||||
company_email,
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
notifyPopup("error",result.message,"success");
|
notifyPopup("error",result.toString(),"success");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
@ -126,9 +132,9 @@ const EmailTemplate = () => {
|
||||||
type="text"
|
type="text"
|
||||||
className="input my-4 "
|
className="input my-4 "
|
||||||
placeholder="Enter company email"
|
placeholder="Enter company email"
|
||||||
name="company_email"
|
name="sender_email"
|
||||||
id="company_email"
|
id="sender_email"
|
||||||
onChange={(e) => setCompany_Email(e.target.value)}
|
onChange={(e) => setSender_Email(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue