fix build
This commit is contained in:
parent
20cc339948
commit
568c6bdcb9
2 changed files with 12 additions and 30 deletions
|
|
@ -1,19 +1,21 @@
|
||||||
import { NextResponse } from "next/server"
|
import { NextResponse } from "next/server"
|
||||||
|
import { ReactElement } from "react"
|
||||||
import { Resend } from "resend"
|
import { Resend } from "resend"
|
||||||
import { EmailTemplate } from "../../../components/Email/EmailTemplate"
|
import { CreateEmailOptions } from "resend/build/src/emails/interfaces"
|
||||||
|
import { EmailTemplate, EmailTemplateProps } from "../../../components/Email/EmailTemplate"
|
||||||
|
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY)
|
const resend = new Resend(process.env.RESEND_API_KEY)
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
const res = await request.json()
|
const res = await request.json()
|
||||||
try {
|
const payload = {
|
||||||
const data = await resend.emails.send({
|
subject: "Contact Form Submission",
|
||||||
subject: res.subject,
|
|
||||||
from: "onboarding@resend.dev",
|
from: "onboarding@resend.dev",
|
||||||
react: EmailTemplate(res),
|
react: EmailTemplate(res as Readonly<EmailTemplateProps>) as ReactElement,
|
||||||
to: "sam.antonis@isacon.be",
|
to: "sam.antonis@isacon.be",
|
||||||
})
|
} as CreateEmailOptions
|
||||||
|
try {
|
||||||
|
const data = await resend.emails.send(payload)
|
||||||
return NextResponse.json(data)
|
return NextResponse.json(data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({ error })
|
return NextResponse.json({ error })
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,10 @@
|
||||||
import { BuildingOffice2Icon, EnvelopeIcon, PhoneIcon } from "@heroicons/react/24/outline"
|
import { BuildingOffice2Icon, EnvelopeIcon, PhoneIcon } from "@heroicons/react/24/outline"
|
||||||
import { FormEvent } from "react"
|
import { FormEvent } from "react"
|
||||||
|
|
||||||
interface EmailData {
|
|
||||||
firstName: {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
lastName: {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
email: {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
message: {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
phoneNumber: {
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Contact() {
|
export default function Contact() {
|
||||||
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const form = event.target as EmailData
|
const form = event.target as HTMLFormElement
|
||||||
|
|
||||||
fetch("/api/send", {
|
fetch("/api/send", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
@ -36,7 +18,6 @@ export default function Contact() {
|
||||||
email: form.email.value,
|
email: form.email.value,
|
||||||
message: form.message.value,
|
message: form.message.value,
|
||||||
phoneNumber: form.phoneNumber.value,
|
phoneNumber: form.phoneNumber.value,
|
||||||
subject: "Contact Form Submission",
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -48,8 +29,7 @@ export default function Contact() {
|
||||||
<div className="mx-auto max-w-xl lg:mx-0 lg:max-w-lg">
|
<div className="mx-auto max-w-xl lg:mx-0 lg:max-w-lg">
|
||||||
<h2 className="text-3xl font-bold tracking-tight text-primary-800">Get in touch</h2>
|
<h2 className="text-3xl font-bold tracking-tight text-primary-800">Get in touch</h2>
|
||||||
<p className="mt-6 text-lg leading-8 text-primary-800">
|
<p className="mt-6 text-lg leading-8 text-primary-800">
|
||||||
Feel free to contact me for any questions or inquiries.
|
Feel free to contact me for any questions or inquiries. we will get back to you as soon as possible.
|
||||||
we will get back to you as soon as possible.
|
|
||||||
</p>
|
</p>
|
||||||
<dl className="mt-10 space-y-4 text-base leading-7 text-primary-800">
|
<dl className="mt-10 space-y-4 text-base leading-7 text-primary-800">
|
||||||
<div className="flex gap-x-4">
|
<div className="flex gap-x-4">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue