Skip to content

Commit

Permalink
fix: contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaynegi45 committed Dec 10, 2024
1 parent 2ad03d8 commit be6de35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/app/api/contact/route.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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: `
<div style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
Expand Down
4 changes: 3 additions & 1 deletion src/app/contactform/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";

import { useState, ChangeEvent, FormEvent } from 'react';
import styles from './ContactForm.module.css';
import {toast} from "sonner";
Expand Down Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion src/components/Faq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit be6de35

Please sign in to comment.