"use client" import React, { useState, useRef } from "react" import { useLanguage } from "@/lib/language-context" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" import { Card } from "@/components/ui/card" import { cn } from "@/lib/utils" import ReCAPTCHA from "react-google-recaptcha" import { Send, CheckCircle2, AlertCircle } from "lucide-react" export default function ContactForm() { const { t } = useLanguage() const recaptchaRef = useRef(null) const [status, setStatus] = useState<"idle" | "loading" | "success" | "error">("idle") const [formData, setFormData] = useState({ name: "", email: "", phone: "", service: "REPTÉRI TRANSZFER", message: "", consent: false }) const handleChange = (e: React.ChangeEvent) => { const { name, value, type } = e.target as any setFormData(prev => ({ ...prev, [name]: type === "checkbox" ? (e.target as HTMLInputElement).checked : value })) } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() const recaptchaValue = recaptchaRef.current?.getValue() if (!recaptchaValue) { alert("Please complete the reCaptcha") return } if (!formData.consent) { alert("Please accept the privacy policy") return } setStatus("loading") try { // In a static export environment, this would hit a PHP script on the server // or an external API. Here we assume an API route for local testing. const response = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...formData, recaptcha: recaptchaValue }) }) if (response.ok) { setStatus("success") setFormData({ name: "", email: "", phone: "", service: "REPTÉRI TRANSZFER", message: "", consent: false }) recaptchaRef.current?.reset() } else { setStatus("error") } } catch (err) { setStatus("error") } } if (status === "success") { return (

Köszönjük!

{t.contactPage.form.success}

) } return (
{/* Name */}
{/* Email */}
{/* Phone */}
{/* Service Type */}
{/* Message */}