'use client'; import { useEffect, useRef, useState } from 'react'; type FormData = { name: string; email: string; company: string; phone: string; message: string; }; type FormErrors = Partial>; type SubmitStatus = 'idle' | 'loading' | 'success' | 'error'; const initialData: FormData = { name: '', email: '', company: '', phone: '', message: '', }; function validateForm(data: FormData): FormErrors { const errors: FormErrors = {}; if (!data.name.trim()) errors.name = 'El nombre es requerido'; if (!data.email.trim()) { errors.email = 'El email es requerido'; } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) { errors.email = 'Ingresa un email válido'; } if (!data.company.trim()) errors.company = 'La empresa es requerida'; if (data.phone && !/^[+\d\s\-().]{7,20}$/.test(data.phone)) { errors.phone = 'Ingresa un teléfono válido'; } return errors; } function LeadForm() { const [formData, setFormData] = useState(initialData); const [errors, setErrors] = useState({}); const [touched, setTouched] = useState>>({}); const [status, setStatus] = useState('idle'); const handleChange = ( e: React.ChangeEvent ) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); if (touched[name as keyof FormData]) { const newErrors = validateForm({ ...formData, [name]: value }); setErrors((prev) => ({ ...prev, [name]: newErrors[name as keyof FormData] })); } }; const handleBlur = ( e: React.FocusEvent ) => { const { name } = e.target; setTouched((prev) => ({ ...prev, [name]: true })); const newErrors = validateForm(formData); setErrors((prev) => ({ ...prev, [name]: newErrors[name as keyof FormData] })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const allTouched = Object.keys(formData).reduce( (acc, k) => ({ ...acc, [k]: true }), {} as Record ); setTouched(allTouched); const validationErrors = validateForm(formData); if (Object.keys(validationErrors).length > 0) { setErrors(validationErrors); return; } setStatus('loading'); await new Promise((resolve) => setTimeout(resolve, 1800)); setStatus('success'); setFormData(initialData); setTouched({}); setErrors({}); }; const handleReset = () => { setStatus('idle'); setFormData(initialData); setErrors({}); setTouched({}); }; if (status === 'success') { return (

¡Mensaje enviado!

Gracias por contactarnos. Nuestro equipo te responderá en menos de 24 horas.

); } return (
{errors.name && touched.name && ( {errors.name} )}
{errors.email && touched.email && ( {errors.email} )}
{errors.company && touched.company && ( {errors.company} )}
{errors.phone && touched.phone && ( {errors.phone} )}

Al enviar, aceptas nuestra{' '} política de privacidad .

); } export default function Hero() { const heroRef = useRef(null); useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { entry.target.classList.add('opacity-100', 'translate-y-0'); entry.target.classList.remove('opacity-0', 'translate-y-6'); } }); }, { threshold: 0.1 } ); const elements = heroRef.current?.querySelectorAll('.reveal'); elements?.forEach((el) => observer.observe(el)); return () => observer.disconnect(); }, []); return (
{/* Grid 2 columnas */}
{/* Columna izquierda — textos */}

Tu reforma,
presupuestada
en 5 minutos.

Deja tu teléfono, sube una foto de tu cocina o baño y te llamamos desde tu provincia en menos de 2 minutos. Al colgar recibirás por WhatsApp el render de tu reforma + presupuesto desglosado.

{/* Stats */}
{/* Columna derecha — formulario */}

Recibe tu presupuesto gratis

Sin compromiso · En menos de 5 minutos


{/* Servicios */}
{[ { icon: ( ), title: 'Reformas Integrales', description: 'Gestionamos tu reforma de principio a fin con un objetivo claro: cumplir plazos y superar expectativas.', }, { icon: ( ), title: 'Reformas de Cocinas', description: 'Transforma tu cocina en el espacio que siempre quisiste. Materiales de calidad, diseño a tu medida.', }, { icon: ( ), title: 'Reformas de Baños', description: 'El baño es el espacio más personal del hogar. Te ayudamos a conseguir el resultado que mereces.', }, ].map(({ icon, title, description }) => (
{icon}

{title}

{description}

))}
); }