fix: contact page now fetches brand info from config
- Created contact API endpoint to store messages - Added contact_messages table - Contact page now displays phone, email, WhatsApp, and address from site config
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useLanguage } from '@/lib/i18n';
|
||||
|
||||
const gold = '#E8A849';
|
||||
@@ -15,7 +15,6 @@ const copy = {
|
||||
email: 'Email',
|
||||
whatsapp: 'WhatsApp',
|
||||
location: 'Location',
|
||||
address: 'Otavalo, Imbabura, Ecuador',
|
||||
send_message: 'Send us a message',
|
||||
form_name: 'Your Name',
|
||||
form_email: 'Your Email',
|
||||
@@ -32,7 +31,6 @@ const copy = {
|
||||
email: 'Correo',
|
||||
whatsapp: 'WhatsApp',
|
||||
location: 'Ubicación',
|
||||
address: 'Otavalo, Imbabura, Ecuador',
|
||||
send_message: 'Envíenos un mensaje',
|
||||
form_name: 'Su Nombre',
|
||||
form_email: 'Su Correo',
|
||||
@@ -49,6 +47,14 @@ export default function ContactPage() {
|
||||
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();
|
||||
@@ -85,28 +91,28 @@ export default function ContactPage() {
|
||||
<div style={{ background: 'rgba(245,240,232,0.06)', borderRadius: '12px', padding: '1.5rem', border: '1px solid rgba(245,240,232,0.12)' }}>
|
||||
<div style={{ fontSize: '24px', marginBottom: '0.5rem' }}>📞</div>
|
||||
<div style={{ fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.1em', color: gold, marginBottom: '0.25rem' }}>{t.phone}</div>
|
||||
<div style={{ fontSize: '16px' }}>+593 99 XXX XXXX</div>
|
||||
<div style={{ fontSize: '16px' }}>{config.phone || '+593 99 XXX XXXX'}</div>
|
||||
</div>
|
||||
|
||||
{/* Email */}
|
||||
<div style={{ background: 'rgba(245,240,232,0.06)', borderRadius: '12px', padding: '1.5rem', border: '1px solid rgba(245,240,232,0.12)' }}>
|
||||
<div style={{ fontSize: '24px', marginBottom: '0.5rem' }}>✉️</div>
|
||||
<div style={{ fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.1em', color: gold, marginBottom: '0.25rem' }}>{t.email}</div>
|
||||
<div style={{ fontSize: '16px' }}>info@lahuasca.com</div>
|
||||
<div style={{ fontSize: '16px' }}>{config.email || 'info@lahuasca.com'}</div>
|
||||
</div>
|
||||
|
||||
{/* WhatsApp */}
|
||||
<div style={{ background: 'rgba(245,240,232,0.06)', borderRadius: '12px', padding: '1.5rem', border: '1px solid rgba(245,240,232,0.12)' }}>
|
||||
<div style={{ fontSize: '24px', marginBottom: '0.5rem' }}>💬</div>
|
||||
<div style={{ fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.1em', color: gold, marginBottom: '0.25rem' }}>{t.whatsapp}</div>
|
||||
<div style={{ fontSize: '16px' }}>+593 99 XXX XXXX</div>
|
||||
<div style={{ fontSize: '16px' }}>{config.whatsapp_url ? <a href={config.whatsapp_url} target="_blank" rel="noopener noreferrer" style={{ color: cream, textDecoration: 'underline' }}>WhatsApp</a> : (config.phone || '+593 99 XXX XXXX')}</div>
|
||||
</div>
|
||||
|
||||
{/* Location */}
|
||||
<div style={{ background: 'rgba(245,240,232,0.06)', borderRadius: '12px', padding: '1.5rem', border: '1px solid rgba(245,240,232,0.12)' }}>
|
||||
<div style={{ fontSize: '24px', marginBottom: '0.5rem' }}>📍</div>
|
||||
<div style={{ fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.1em', color: gold, marginBottom: '0.25rem' }}>{t.location}</div>
|
||||
<div style={{ fontSize: '16px' }}>{t.address}</div>
|
||||
<div style={{ fontSize: '16px' }}>{config.address || 'Otavalo, Imbabura, Ecuador'}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user