Remove hCaptcha integration from contact form and API route
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import React, {useRef, useState} from 'react'
|
||||
import React, {useState} from 'react'
|
||||
import {motion} from 'framer-motion'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import HCaptcha from '@hcaptcha/react-hcaptcha'
|
||||
|
||||
const ContactFormSection = () => {
|
||||
const captchaRef = useRef<HCaptcha | null>(null)
|
||||
|
||||
const [form, setForm] = useState({
|
||||
name: '',
|
||||
email: '',
|
||||
@@ -17,7 +14,6 @@ const ContactFormSection = () => {
|
||||
message: '',
|
||||
})
|
||||
|
||||
const [captchaToken, setCaptchaToken] = useState('')
|
||||
const [submitted, setSubmitted] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
@@ -33,16 +29,10 @@ const ContactFormSection = () => {
|
||||
setLoading(true)
|
||||
setError('')
|
||||
|
||||
if (!captchaToken) {
|
||||
setError('Bitte bestätige, dass du kein Roboter bist.')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const res = await fetch('/api/contact', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({...form, captcha: captchaToken}),
|
||||
body: JSON.stringify(form),
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
@@ -55,8 +45,6 @@ const ContactFormSection = () => {
|
||||
website: '',
|
||||
message: '',
|
||||
})
|
||||
setCaptchaToken('')
|
||||
captchaRef.current?.resetCaptcha()
|
||||
} else {
|
||||
const resJson = await res.json()
|
||||
setError(
|
||||
@@ -178,20 +166,6 @@ const ContactFormSection = () => {
|
||||
/>
|
||||
</motion.div>
|
||||
|
||||
<motion.div
|
||||
className="pt-2"
|
||||
initial={{opacity: 0, y: 10}}
|
||||
whileInView={{opacity: 1, y: 0}}
|
||||
viewport={{once: true}}
|
||||
transition={{duration: 0.5, delay: 0.7}}
|
||||
>
|
||||
<HCaptcha
|
||||
sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY!}
|
||||
onVerify={(token) => setCaptchaToken(token)}
|
||||
ref={captchaRef}
|
||||
/>
|
||||
</motion.div>
|
||||
|
||||
{error && (
|
||||
<div className="text-red-600 font-medium pt-2">❌ {error}</div>
|
||||
)}
|
||||
@@ -213,4 +187,4 @@ const ContactFormSection = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export default ContactFormSection
|
||||
export default ContactFormSection
|
||||
Reference in New Issue
Block a user