'use client'; import { useState, useEffect } from 'react'; import { useLanguage } from '@/lib/i18n'; const gold = '#E8A849'; const navy = '#010D1E'; const cream = '#f5f0e8'; const copy = { en: { title: 'Contact Us', subtitle: 'Get in touch with us', phone: 'Phone', email: 'Email', whatsapp: 'WhatsApp', location: 'Location', send_message: 'Send us a message', form_name: 'Your Name', form_email: 'Your Email', form_message: 'Message', form_submit: 'Send Message', form_sending: 'Sending...', form_success: 'Message sent successfully!', form_error: 'Failed to send message. Please try again.', }, es: { title: 'Contáctenos', subtitle: 'Póngase en contacto con nosotros', phone: 'Teléfono', email: 'Correo', whatsapp: 'WhatsApp', location: 'Ubicación', send_message: 'Envíenos un mensaje', form_name: 'Su Nombre', form_email: 'Su Correo', form_message: 'Mensaje', form_submit: 'Enviar Mensaje', form_sending: 'Enviando...', form_success: '¡Mensaje enviado exitosamente!', form_error: 'Error al enviar el mensaje. Intente de nuevo.', }, }; export default function ContactPage() { const language = useLanguage(); const t = copy[language]; const [form, setForm] = useState({ name: '', email: '', message: '' }); const [status, setStatus] = useState<'idle' | 'sending' | 'success' | 'error'>('idle'); const [config, setConfig] = useState<{ phone?: string; email?: string; whatsapp_url?: string; address?: string }>({}); useEffect(() => { fetch('/api/site-assets') .then(res => res.json()) .then(data => setConfig(data.data || {})) .catch(() => {}); }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setStatus('sending'); try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(form), }); if (res.ok) { setStatus('success'); setForm({ name: '', email: '', message: '' }); } else { setStatus('error'); } } catch { setStatus('error'); } }; return (

{t.title}

{t.subtitle}

{/* Phone */}
📞
{t.phone}
{config.phone || '+593 99 XXX XXXX'}
{/* Email */}
✉️
{t.email}
{config.email || 'info@lahuasca.com'}
{/* WhatsApp */}
💬
{t.whatsapp}
{config.whatsapp_url ? WhatsApp : (config.phone || '+593 99 XXX XXXX')}
{/* Location */}
📍
{t.location}
{config.address || 'Otavalo, Imbabura, Ecuador'}
{/* Contact Form */}

{t.send_message}

setForm({ ...form, name: e.target.value })} required style={{ padding: '0.875rem 1rem', background: 'rgba(245,240,232,0.08)', border: '1px solid rgba(245,240,232,0.2)', borderRadius: '8px', color: cream, fontSize: '15px', }} /> setForm({ ...form, email: e.target.value })} required style={{ padding: '0.875rem 1rem', background: 'rgba(245,240,232,0.08)', border: '1px solid rgba(245,240,232,0.2)', borderRadius: '8px', color: cream, fontSize: '15px', }} />