feat: ContactUs Nodemailer
This commit is contained in:
parent
3f7bd63c8b
commit
8764222e91
1 changed files with 11 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
import { Button } from "components/Button/Button"
|
import { Button } from "components/Button/Button"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import MoveUpWhenVisible from "utils/ScrollAnimations/MoveUpOnScroll"
|
import MoveUpWhenVisible from "utils/ScrollAnimations/MoveUpOnScroll"
|
||||||
import { Toaster, toast } from "sonner"
|
import { toast, Toaster } from "sonner"
|
||||||
|
|
||||||
interface ResponseData {
|
interface ResponseData {
|
||||||
success: boolean
|
success: boolean
|
||||||
|
|
@ -29,10 +29,17 @@ export default function ContactUs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
console.log(e)
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setSubmiting(true)
|
setSubmiting(true)
|
||||||
|
|
||||||
|
function clearForm() {
|
||||||
|
setFormData({
|
||||||
|
email: "",
|
||||||
|
subject: "",
|
||||||
|
message: "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch("/api/routes", {
|
const response = await fetch("/api/routes", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -46,8 +53,10 @@ export default function ContactUs() {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
toast.success("Message sent successfully")
|
toast.success("Message sent successfully")
|
||||||
|
clearForm()
|
||||||
} else {
|
} else {
|
||||||
toast.error("Something went wrong. Please try again later")
|
toast.error("Something went wrong. Please try again later")
|
||||||
|
clearForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
setSubmiting(false)
|
setSubmiting(false)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue