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 c941133 commit 2ad03d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/app/api/contact/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export async function POST(request: Request) {
</div>
`,
});
console.log(process.env.SENDER_EMAIL);
console.log(process.env.CONTACT_FORM_RECEIVER_EMAIL);

return NextResponse.json({ message: 'Email sent successfully.' }, { status: 200 });
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/contactform/ContactForm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

.input:focus,
.textarea:focus {
border-color: #0070f3;
border-color: var(--green);
}

/* Textarea styles */
Expand Down
38 changes: 19 additions & 19 deletions src/app/contactform/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ export default function ContactForm() {
};

const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
// e.preventDefault();
//
// try {
// const res = await fetch('/api/contact', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify(formData),
// });
//
// if (res.ok) {
// 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");
// }
// } catch (error) {
// toast.error("An unexpected error occurred. Please try again.");
// }
e.preventDefault();

try {
const res = await fetch('/api/contact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),
});

if (res.ok) {
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");
}
} catch (error) {
toast.error("An unexpected error occurred. Please try again.");
}


};
toast.info("Currently Working on this form!");
// toast.info("Currently Working on this form!");

return (
<div className={styles.container}>
Expand Down

0 comments on commit 2ad03d8

Please sign in to comment.