/* global React, Placeholder, SectionHead, StarRow */ // ───────────── GERENTE ───────────── const Gerente = ({ onReserve }) => (
FUNDADOR
Matías Bread
— MENSAJE —

"Empecé a cortar el pelo a los dieciséis. Hoy, una década después, quiero que cada cliente sienta que pasar por nuestra silla es un acto de cuidado, no un trámite."

); const Stat = ({ label, value }) => (
{label}
{value}
); // ───────────── RESERVAS (inline mini form) ───────────── const SERVICES_LIST = [ { id: 's1', name: 'Corte clásico', time: '40min', price: 10000 }, { id: 's2', name: 'Fade premium', time: '50min', price: 13000 }, { id: 's5', name: 'Tratamiento barba', time: '40min', price: 13000 }, { id: 's6', name: 'Pack Bread Way', time: '90min', price: 24000 }, ]; const BARBERS = [ { id: 'b1', name: 'Matías', role: 'Fundador' }, { id: 'b2', name: 'Diego', role: 'Barber' }, { id: 'b3', name: 'Andrés', role: 'Barber' }, ]; const TIMES = ['12:00', '13:30', '15:00', '16:30', '18:00', '19:00']; const Reservas = () => { const [service, setService] = React.useState('s2'); const [barber, setBarber] = React.useState('b1'); const [day, setDay] = React.useState(2); const [time, setTime] = React.useState('15:00'); const [nombre, setNombre] = React.useState(''); const [telefono, setTelefono] = React.useState(''); const [enviando, setEnviando] = React.useState(false); const [error, setError] = React.useState(''); const days = React.useMemo(() => { const today = new Date(); return Array.from({ length: 7 }, (_, i) => { const d = new Date(today); d.setDate(today.getDate() + i); return d; }); }, []); const dayLabels = ['Dom','Lun','Mar','Mié','Jue','Vie','Sáb']; const monthLabels = ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic']; const selected = SERVICES_LIST.find(s => s.id === service); const selBarber = BARBERS.find(b => b.id === barber); const selDate = days[day]; const confirmar = async () => { setError(''); if (!nombre.trim() || !telefono.trim()) { setError('Completa tu nombre y teléfono para reservar.'); return; } const fechaTexto = `${dayLabels[selDate.getDay()]} ${selDate.getDate()} ${monthLabels[selDate.getMonth()]}`; setEnviando(true); try { await fetch('/guardar-reserva.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ servicio: selected.name, precio: selected.price, profesional: selBarber.name, fecha: fechaTexto, hora: time, cliente_nombre: nombre.trim(), cliente_telefono: telefono.trim(), }), }); } catch (e) { // Si falla el guardado igual dejamos que el cliente confirme por WhatsApp. } setEnviando(false); const texto = `Hola! Quiero reservar:\n• Nombre: ${nombre.trim()}\n• Servicio: ${selected.name}\n• Profesional: ${selBarber.name}\n• Fecha: ${fechaTexto}\n• Hora: ${time}\n• Total: $${selected.price.toLocaleString('es-CL')}`; window.open(`https://wa.me/56984740024?text=${encodeURIComponent(texto)}`, '_blank', 'noreferrer'); }; const pagarConTarjeta = async () => { setError(''); if (!nombre.trim() || !telefono.trim()) { setError('Completa tu nombre y teléfono para reservar.'); return; } const fechaTexto = `${dayLabels[selDate.getDay()]} ${selDate.getDate()} ${monthLabels[selDate.getMonth()]}`; setEnviando(true); try { const res = await fetch('/guardar-reserva.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ servicio: selected.name, precio: selected.price, profesional: selBarber.name, fecha: fechaTexto, hora: time, cliente_nombre: nombre.trim(), cliente_telefono: telefono.trim(), }), }); const data = await res.json(); if (!data || !data.id) throw new Error('sin id'); const form = document.createElement('form'); form.method = 'POST'; form.action = '/pago/iniciar.php'; form.style.display = 'none'; form.innerHTML = '' + ''; document.body.appendChild(form); form.submit(); } catch (e) { setEnviando(false); setError('No se pudo iniciar el pago con tarjeta. Intenta de nuevo o confirma por WhatsApp.'); } }; return (
{/* 1. Service */}
{SERVICES_LIST.map(s => ( ))}
{/* 2. Barber */}
{BARBERS.map(b => ( ))}
{/* 3. Day */}
{days.map((d, i) => ( ))}
{/* 4. Time */}
{TIMES.map(t => ( ))}
{/* 5. Datos de contacto */}
setNombre(e.target.value)} style={{ padding: '12px 14px', border: '1px solid var(--line)', background: 'var(--paper)', color: 'var(--ink)', fontFamily: 'Inter, sans-serif', fontSize: 14, }} /> setTelefono(e.target.value)} style={{ padding: '12px 14px', border: '1px solid var(--line)', background: 'var(--paper)', color: 'var(--ink)', fontFamily: 'Inter, sans-serif', fontSize: 14, }} />
{/* Summary */}
— RESUMEN —
{error && (
{error}
)}
Recibirás confirmación por WhatsApp al +56 9 8474 0024
); }; const Field = ({ label, children }) => (
{label}
{children}
); const SummaryRow = ({ label, value, bold }) => (
{label} {value}
); Object.assign(window, { Gerente, Reservas });