From 568c6bdcb9ddc3105d209b7305dabe4239a67089 Mon Sep 17 00:00:00 2001 From: isaconantonis Date: Fri, 4 Aug 2023 11:12:10 +0200 Subject: [PATCH] fix build --- app/api/send/route.ts | 18 ++++++++++-------- app/contact/page.tsx | 24 ++---------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/app/api/send/route.ts b/app/api/send/route.ts index 450b687..2c90a9a 100644 --- a/app/api/send/route.ts +++ b/app/api/send/route.ts @@ -1,19 +1,21 @@ import { NextResponse } from "next/server" +import { ReactElement } from "react" 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) export async function POST(request: Request) { const res = await request.json() + const payload = { + subject: "Contact Form Submission", + from: "onboarding@resend.dev", + react: EmailTemplate(res as Readonly) as ReactElement, + to: "sam.antonis@isacon.be", + } as CreateEmailOptions try { - const data = await resend.emails.send({ - subject: res.subject, - from: "onboarding@resend.dev", - react: EmailTemplate(res), - to: "sam.antonis@isacon.be", - }) - + const data = await resend.emails.send(payload) return NextResponse.json(data) } catch (error) { return NextResponse.json({ error }) diff --git a/app/contact/page.tsx b/app/contact/page.tsx index 5064cbc..b068aae 100644 --- a/app/contact/page.tsx +++ b/app/contact/page.tsx @@ -2,28 +2,10 @@ import { BuildingOffice2Icon, EnvelopeIcon, PhoneIcon } from "@heroicons/react/24/outline" 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() { function handleSubmit(event: FormEvent) { event.preventDefault() - const form = event.target as EmailData + const form = event.target as HTMLFormElement fetch("/api/send", { method: "POST", @@ -36,7 +18,6 @@ export default function Contact() { email: form.email.value, message: form.message.value, phoneNumber: form.phoneNumber.value, - subject: "Contact Form Submission", }), }) } @@ -48,8 +29,7 @@ export default function Contact() {

Get in touch

- Feel free to contact me for any questions or inquiries. - we will get back to you as soon as possible. + Feel free to contact me for any questions or inquiries. we will get back to you as soon as possible.