"use client"; import { useState } from "react"; import { Mail, Send, CheckCircle2 } from "lucide-react"; interface NoAvailabilityContactProps { locale: string; /** e.g. the searched arrival/departure dates, sent along for context. */ context?: string; } export function NoAvailabilityContact({ locale, context }: NoAvailabilityContactProps) { const [email, setEmail] = useState(""); const [message, setMessage] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const [sent, setSent] = useState(false); const isDe = locale === "de"; async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!email || !message) return; setLoading(true); setError(""); try { const res = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, message, context }), }); if (!res.ok) { throw new Error("Failed to send message"); } setSent(true); } catch { setError( isDe ? "Ihre Nachricht konnte nicht gesendet werden. Bitte versuchen Sie es erneut oder schreiben Sie uns direkt an info@bb-apartment.de." : "Your message could not be sent. Please try again or email us directly at info@bb-apartment.de." ); } finally { setLoading(false); } } if (sent) { return (

{isDe ? "Nachricht gesendet!" : "Message sent!"}

{isDe ? "Danke für Ihre Anfrage. Wir melden uns so schnell wie möglich bei Ihnen." : "Thank you for reaching out. We'll get back to you as soon as possible."}

); } return (

{isDe ? "Kein passendes Apartment gefunden?" : "Can't find what you're looking for?"}

{isDe ? "Schreiben Sie uns kurz Ihre Wunschtermine und Anforderungen — wir melden uns persönlich bei Ihnen, auch für individuelle Anfragen oder Wartelisten." : "Tell us your preferred dates and requirements — we'll get back to you personally, including for custom requests or waitlists."}

setEmail(e.target.value)} className="w-full px-4 py-3 rounded-xl border border-brand-grey-soft focus:border-brand-green focus:ring-1 focus:ring-brand-green outline-none" />