diff --git a/.env b/.env index f686a7c..f689d91 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -NEXT_PUBLIC_ZOHO_PASS=bw8gDdMm5P7i \ No newline at end of file +NEXT_PUBLIC_ZOHO_PASS=bw8gDdMm5P7i +NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY=0x4AAAAAAAYF95fpqit1gynJ diff --git a/app/api/routes/route.ts b/app/api/routes/route.ts index 36bdbea..e519e24 100644 --- a/app/api/routes/route.ts +++ b/app/api/routes/route.ts @@ -20,12 +20,13 @@ export async function POST(req: any) { const plainTextContent = stripHTMLTags(htmlContent) try { - await transporter.sendMail({ - ...mailOptions, - subject: `Contact Inquiry - VizoleLabs Web`, - text: plainTextContent, - html: htmlContent, - }) + console.log(req.headers) + // await transporter.sendMail({ + // ...mailOptions, + // subject: `Contact Inquiry - VizoleLabs Web`, + // text: plainTextContent, + // html: htmlContent, + // }) return NextResponse.json({ success: true }) } catch (error: any) { console.error(error) diff --git a/components/ContactUs/ContactUs.tsx b/components/ContactUs/ContactUs.tsx index 5968d8a..96323ab 100644 --- a/components/ContactUs/ContactUs.tsx +++ b/components/ContactUs/ContactUs.tsx @@ -4,6 +4,8 @@ import { Button } from "components/Button/Button" import { useState } from "react" import MoveUpWhenVisible from "utils/ScrollAnimations/MoveUpOnScroll" import { toast, Toaster } from "sonner" +import Script from "next/script" +import { copyFile } from "fs" interface ResponseData { success: boolean @@ -15,6 +17,7 @@ export default function ContactUs() { email: "", subject: "", message: "", + token: "", }) const [submiting, setSubmiting] = useState(false) @@ -31,15 +34,25 @@ export default function ContactUs() { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setSubmiting(true) - + const submitdata = new FormData(e.currentTarget) + const token = submitdata.get("cf-turnstile-response") + if (!token) { + toast.error("Please complete the captcha") + setSubmiting(false) + return + } + setFormData({ + ...formData, + token: token as string, + }) function clearForm() { setFormData({ email: "", subject: "", message: "", + token: "", }) } - const response = await fetch("/api/routes", { method: "POST", headers: { @@ -63,75 +76,83 @@ export default function ContactUs() { } return ( -
- -

- Contact Us -

-
- -

- Got a technical issue? Want to send feedback about a beta feature? Need details about our Business plan? Let - us know. -

-
- -
-
- - + +
+ +

+ Contact Us +

+
+ +

+ Got a technical issue? Want to send feedback about a beta feature? Need details about our Business plan? Let + us know. +

+
+ + +
+ + +
+
+ + +
+
+ + +
+
+ -
-
- - -
-
- - -
- - - - + + + +
) }