From be6de356806051d65ba99c2e8c62e14a7bd32e09 Mon Sep 17 00:00:00 2001 From: ajaynegi45 Date: Wed, 11 Dec 2024 00:12:13 +0530 Subject: [PATCH] fix: contact page --- src/app/api/contact/route.ts | 6 ++++-- src/app/contactform/page.tsx | 4 +++- src/components/Faq.tsx | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/api/contact/route.ts b/src/app/api/contact/route.ts index 998510d..ec5c715 100644 --- a/src/app/api/contact/route.ts +++ b/src/app/api/contact/route.ts @@ -1,6 +1,8 @@ import { NextResponse } from 'next/server'; import mailer from '@/lib/mailer'; +const senderEmail = process.env.SENDER_EMAIL; +const receiverEmail = process.env.CONTACT_FORM_RECEIVER_EMAIL export async function POST(request: Request) { try { const { name, email, reason, message } = await request.json(); @@ -11,8 +13,8 @@ export async function POST(request: Request) { // Send the email using Nodemailer await mailer.sendMail({ - from: process.env.SENDER_EMAIL, - to: process.env.CONTACT_FORM_RECEIVER_EMAIL, + from: `Contact Form <${senderEmail}>`, + to: receiverEmail, subject: `Contact Form: ${reason}`, html: `
diff --git a/src/app/contactform/page.tsx b/src/app/contactform/page.tsx index 4b17564..2b3ad00 100644 --- a/src/app/contactform/page.tsx +++ b/src/app/contactform/page.tsx @@ -1,4 +1,5 @@ "use client"; + import { useState, ChangeEvent, FormEvent } from 'react'; import styles from './ContactForm.module.css'; import {toast} from "sonner"; @@ -36,7 +37,8 @@ export default function ContactForm() { }); if (res.ok) { - toast.success("Thank you for contacting us! Your message has been sent."); + console.log(res); + toast.success("Thank you for contacting us! Your message has been sent." ,); setFormData({ name: '', email: '', reason: '', message: '' }); } else { toast.error("There was a problem sending the message. Please try again"); diff --git a/src/components/Faq.tsx b/src/components/Faq.tsx index ed3acaa..d853056 100644 --- a/src/components/Faq.tsx +++ b/src/components/Faq.tsx @@ -3,7 +3,6 @@ import Image from "next/image"; import styles from "../components/ui/Faq.module.css"; import Chat from "/public/chat.svg"; import Link from "next/link"; -import Page from "@/app/contactform/page"; const Faq: React.FC = () => { const [faqs, setFaqs] = useState([