update form
This commit is contained in:
parent
1ac6d87a89
commit
0205e2b177
@ -1,6 +1,10 @@
|
|||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
|
|
||||||
export default async function submitContactForm(e: any, setSuccess: Dispatch<SetStateAction<string | null>>, setLoading: Dispatch<SetStateAction<boolean>>) {
|
export default async function submitContactForm(
|
||||||
|
e: any,
|
||||||
|
setSuccess: Dispatch<SetStateAction<string | null>>,
|
||||||
|
setLoading: Dispatch<SetStateAction<boolean>>
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@ -15,6 +19,7 @@ export default async function submitContactForm(e: any, setSuccess: Dispatch<Set
|
|||||||
message: message,
|
message: message,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
let res = await fetch("/api/contactForm", {
|
let res = await fetch("/api/contactForm", {
|
||||||
method: "post",
|
method: "post",
|
||||||
headers: {
|
headers: {
|
||||||
@ -37,4 +42,7 @@ export default async function submitContactForm(e: any, setSuccess: Dispatch<Set
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Form submission failed. Please try again in a minute.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { NextApiRequest, NextApiResponse } from "next";
|
|||||||
|
|
||||||
let transporter = nodemailer.createTransport({
|
let transporter = nodemailer.createTransport({
|
||||||
host: process.env.TBENMAIL_HOST,
|
host: process.env.TBENMAIL_HOST,
|
||||||
port: 587,
|
port: 465,
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.TBENMAIL_EMAIL,
|
user: process.env.TBENMAIL_EMAIL,
|
||||||
pass: process.env.TBENMAIL_EMAIL_PASSWORD,
|
pass: process.env.TBENMAIL_EMAIL_PASSWORD,
|
||||||
@ -46,7 +46,9 @@ export default async function handler(
|
|||||||
res.json({ msg: "Success", info: info });
|
res.json({ msg: "Success", info: info });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
res.json({ msg: "Failed" });
|
res.json({
|
||||||
|
msg: "Please try again in a minute.",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user