all emails working when a customer submits an order
This commit is contained in:
parent
a75956c569
commit
5f0e56abec
Binary file not shown.
@ -31,7 +31,7 @@ export const sendEmail = async (formData: FormData) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
from:"Order Form <orders@kevosattire.com>",
|
from:"Kevos Official <orders@kevosattire.com>",
|
||||||
// to:"arcjcb11@gmail.com",
|
// to:"arcjcb11@gmail.com",
|
||||||
to: senderEmail as string,
|
to: senderEmail as string,
|
||||||
subject: "New Order",
|
subject: "New Order",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { sendEmail } from "@/lib/mail.utils"
|
import { sendEmails } from "@/lib/mail.utils"
|
||||||
|
import { NextRequest } from "next/server"
|
||||||
|
|
||||||
export async function POST() {
|
export async function POST(request: NextRequest) {
|
||||||
const sender = {
|
const sender = {
|
||||||
name: 'Kevos Official',
|
name: 'Kevos Official',
|
||||||
address: 'no-reply@kevosattire.com',
|
address: 'no-reply@kevosattire.com',
|
||||||
@ -11,12 +12,14 @@ export async function POST() {
|
|||||||
address: 'arcjcb11@gmail.com',
|
address: 'arcjcb11@gmail.com',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
const clientEmail = await request.json();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
const result = await sendEmail({
|
const result = await sendEmails({
|
||||||
sender,
|
sender,
|
||||||
recipients,
|
recipients,
|
||||||
subject: "New Email!",
|
subject: "New Email!",
|
||||||
message: "We will follow up with a Paypal invoice soon!"
|
message: `New order from ${clientEmail}`
|
||||||
})
|
})
|
||||||
|
|
||||||
return Response.json({
|
return Response.json({
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import ClientPortal from "@/components/ClientPortal/ClientPortal";
|
|||||||
import styles from "@/styles/Home.module.css";
|
import styles from "@/styles/Home.module.css";
|
||||||
import { Poppins } from "next/font/google";
|
import { Poppins } from "next/font/google";
|
||||||
import { sendEmail } from "./actions/sendEmail";
|
import { sendEmail } from "./actions/sendEmail";
|
||||||
import { selfEmail } from "./api/emails/route";
|
import { sendEmails } from "@/lib/mail.utils";
|
||||||
|
|
||||||
const Popp = Poppins({ weight: "400", subsets: ["latin"] });
|
const Popp = Poppins({ weight: "400", subsets: ["latin"] });
|
||||||
|
|
||||||
@ -33,10 +33,24 @@ export default function Home() {
|
|||||||
// console.log({email:formData.get("email"), order:formData.get("order")})
|
// console.log({email:formData.get("email"), order:formData.get("order")})
|
||||||
|
|
||||||
// Send client email
|
// Send client email
|
||||||
// await sendEmail(formData);
|
await sendEmail(formData);
|
||||||
|
|
||||||
// Send new order email to self
|
// Send new order email to self
|
||||||
// await selfEmail(formData);
|
const clientEmail = formData.get('senderEmail') as string
|
||||||
|
await fetch("/api/emails", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(clientEmail),
|
||||||
|
})
|
||||||
|
// .then((response) => response.json())
|
||||||
|
// .then((data) => {
|
||||||
|
// console.log(data);
|
||||||
|
// })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// const response = await fetch("http://192.168.50.107:5580/new-order", {
|
// const response = await fetch("http://192.168.50.107:5580/new-order", {
|
||||||
@ -60,7 +74,7 @@ export default function Home() {
|
|||||||
emails: "",
|
emails: "",
|
||||||
orders: "",
|
orders: "",
|
||||||
});
|
});
|
||||||
alert("Order Placed! Please check your email.")
|
// alert("Order Placed! Please check your email.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -20,7 +20,7 @@ type SendEmailDto = {
|
|||||||
message: string;
|
message: string;
|
||||||
// react: React.ReactNode;
|
// react: React.ReactNode;
|
||||||
}
|
}
|
||||||
export const sendEmail = async (dto: SendEmailDto) => {
|
export const sendEmails = async (dto: SendEmailDto) => {
|
||||||
const { sender, recipients, subject, message} = dto;
|
const { sender, recipients, subject, message} = dto;
|
||||||
|
|
||||||
return await transport.sendMail({
|
return await transport.sendMail({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user