feat: ContactUs Nodemailer

This commit is contained in:
Dex404 2024-04-22 05:20:59 +00:00
parent 3f7bd63c8b
commit 8764222e91

View file

@ -3,7 +3,7 @@
import { Button } from "components/Button/Button"
import { useState } from "react"
import MoveUpWhenVisible from "utils/ScrollAnimations/MoveUpOnScroll"
import { Toaster, toast } from "sonner"
import { toast, Toaster } from "sonner"
interface ResponseData {
success: boolean
@ -29,10 +29,17 @@ export default function ContactUs() {
}
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
console.log(e)
e.preventDefault()
setSubmiting(true)
function clearForm() {
setFormData({
email: "",
subject: "",
message: "",
})
}
const response = await fetch("/api/routes", {
method: "POST",
headers: {
@ -46,8 +53,10 @@ export default function ContactUs() {
if (success) {
toast.success("Message sent successfully")
clearForm()
} else {
toast.error("Something went wrong. Please try again later")
clearForm()
}
setSubmiting(false)