/* Cierre de campaña + Footer + Chat flotante + Carrito */
const { Ic: I2 } = window;
const DD = window.DianeryData;
/* Carrito lateral */
function CartDrawer({ open, onClose }) {
if (!open) return null;
const lines = DD.getCartDetailed();
const total = DD.cartTotal();
const checkout = () => {
if (!lines.length) return;
if (!DD.getWhatsappNumber()) {
window.shopToast && window.shopToast("Configura un WhatsApp en Admin → Contacto");
return;
}
window.open(DD.whatsappOrderUrl(), "_blank", "noopener");
};
return (
{lines.length === 0 ? (
) : (
{lines.map(l => {
const img = (l.product.images || [])[0];
return (
{l.product.name}
{DD.formatCOP(l.product.price)} c/u
{l.qty}
{DD.formatCOP(l.product.price * l.qty)}
);
})}
Total{DD.formatCOP(total)}
)}
);
}
/* Toast simple de la tienda */
function ShopToast() {
const [msg, setMsg] = React.useState(null);
React.useEffect(() => {
window.shopToast = (m) => {
setMsg(m);
clearTimeout(window.__shopToastT);
window.__shopToastT = setTimeout(() => setMsg(null), 2200);
};
}, []);
if (!msg) return null;
return {msg}
;
}
function ClosingCampaign({ data }) {
if (!data || !data.enabled) return null;
return (
{data.kicker}
{data.title}
{data.highlightedText && {data.highlightedText}
}
);
}
/* Enlaces sin destino real → "Próximamente"; con URL real → navega normal */
function footLink(e, href) {
if (!href || href === "#") {
e.preventDefault();
window.shopToast && window.shopToast("Próximamente");
}
}
function ContactItem({ icon, label, value }) {
if (!value) return null;
const Icon = I2[icon];
return (
{Icon && }
{label}
{value}
);
}
function Footer({ data, brand }) {
const c = data.contact || {};
const legal = data.legal || {};
const socials = (data.socialLinks || []).filter(s => I2[s.icon]);
return (
);
}
function FloatingChat({ data }) {
if (!data || !data.enabled) return null;
const Icon = data.provider === "whatsapp" ? I2.whatsapp : I2.chat;
const real = data.href && data.href !== "#";
const num = DD.getWhatsappNumber();
const onClick = (e) => {
if (real) return; // usa el enlace configurado
e.preventDefault();
if (num) window.open(`https://wa.me/${num}`, "_blank", "noopener");
else window.shopToast && window.shopToast("Configura un WhatsApp en Admin → Contacto");
};
return (
{data.label}
);
}
Object.assign(window, { ClosingCampaign, Footer, FloatingChat, CartDrawer, ShopToast });