'use client'; import { useState } from 'react'; import { Check, Loader2 } from 'lucide-react'; interface Props { productName: string; productSku: string; } export default function MultisplitContactForm({ productName, productSku }: Props) { const [form, setForm] = useState({ name: '', phone: '', email: '', city: '', rooms: '2', message: '', consent: false, }); const [loading, setLoading] = useState(false); const [sent, setSent] = useState(false); const [error, setError] = useState(''); const handle = (e: React.ChangeEvent) => { const { name, value, type } = e.target; setForm(prev => ({ ...prev, [name]: type === 'checkbox' ? (e.target as HTMLInputElement).checked : value, })); }; const submit = async () => { if (!form.name || !form.phone || !form.consent) { setError('Wypełnij wymagane pola i zaznacz zgodę.'); return; } setLoading(true); setError(''); try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: form.name, phone: form.phone, email: form.email, city: form.city, subject: `Zapytanie o multisplit: ${productName} (${productSku})`, message: `Liczba pomieszczeń: ${form.rooms}\n\n${form.message}`, }), }); if (res.ok) setSent(true); else setError('Błąd wysyłki. Zadzwoń do nas bezpośrednio.'); } catch { setError('Błąd połączenia. Spróbuj ponownie.'); } setLoading(false); }; if (sent) { return (

Zapytanie wysłane!

Oddzwonimy w ciągu 24 godzin z bezpłatną wyceną.

); } return (
{/* Produkt info */}
Zapytanie dotyczy: {productName}