/* global React, useUI, useWishlist, Placeholder, HeartIcon, Arr, waLink */ const { useEffect } = React; function Modal() { const ui = useUI(); const wl = useWishlist(); const p = ui.modal; useEffect(() => { if (!p) return; const onKey = (e) => { if (e.key === "Escape") ui.closeModal(); }; window.addEventListener("keydown", onKey); document.body.style.overflow = "hidden"; return () => { window.removeEventListener("keydown", onKey); document.body.style.overflow = ""; }; }, [p]); if (!p) return null; const isOn = wl.has(p.id); // Handle both raw catalog format (nombre/foto/precio) and transformed format (name/photo/price) const name = p.name || p.nombre || ""; const photo = p.photo || p.foto || null; const price = p.price || (p.precio ? p.precio.toLocaleString("es-CO") : ""); const family = p.family || (p.categoria ? (window.CAT_LABELS && window.CAT_LABELS[p.categoria]) || p.categoria : ""); const pattern = p.pattern || (typeof detectarPatron === "function" ? detectarPatron(p.variante) : null) || ""; const variant = p.variante || ""; const wmsg = `Hola DAVA'S, me interesa la ${name}${pattern ? ` patrón ${pattern}` : ""}${price ? ` ($${price})` : ""}. ¿Me cuentan disponibilidad?`; return (
{ if (e.target.classList.contains("modal-back")) ui.closeModal(); }}>
{photo ? ( {name} ) : ( )}
{family}

{name}

{pattern ?
{pattern}
: null} {variant && variant !== pattern ?
{variant}
: null}
$ {price}
Hecha a pedido · 15 días
Pedir por WhatsApp
); } window.Modal = Modal;