/* global React, Icon, Button, Badge, ProductCard, CanVisual, ProductMedia, SwatchGrid, PresentationSelector, StockLabel, useState, useEffect, useRef */
/* ============================ HOME ============================ */
// Paleta acotada para el hero interactivo: cruza familias reales de NOGO.palette
// (azul de marca + frío + cálido + verde + neutro) — variedad sin choques de color.
const HERO_COLORS = [
{ name: "Azul Nogopaint", hex: "#0077b6" },
{ name: "Azul Noche", hex: "#283a63" },
{ name: "Terracota", hex: "#bd6a48" },
{ name: "Verde Salvia", hex: "#9aa881" },
{ name: "Gris Plomo", hex: "#73767a" },
];
function HomeScreen({ go, openProduct, startAdvisor }) {
const NOGO = window.NOGO;
const featured = NOGO.products.filter((p) => p.featured);
const [heroColor, setHeroColor] = useState(HERO_COLORS[0]);
const [heroTick, setHeroTick] = useState(0);
const pickHeroColor = (c) => { setHeroColor(c); setHeroTick((t) => t + 1); };
const heroKey = `${heroColor.hex}-${heroTick}`;
const cats = [
{ id: "interior", label: "Interior", icon: "home", hex: "#a8c8e0" },
{ id: "exterior", label: "Exterior", icon: "shield", hex: "#9aa881" },
{ id: "esmaltes", label: "Esmaltes", icon: "brush", hex: "#e8a48b" },
{ id: "impermeab", label: "Impermeab.", icon: "drop", hex: "#cdbfa3" },
];
return (
{/* Hero */}
Asesoramiento experto, gratis
Pintá con la cantidad justa.
Nilo calcula cuántos litros necesitás según tus m². Elegí color, presentación y comprá sin desperdicio.
¿Qué color pintamos?
{HERO_COLORS.map((c) => (
))}
Interior
20 L
45 m² · 2 manos → 10 L
Calculado por Nilo
{/* Categorías */}
Categorías
{cats.map((c) => (
))}
{/* Destacados */}
Más vendidos
{/* Banner bot */}
¿Cuánta pintura necesito?
Nuestro asesor calcula los litros exactos al agregar un producto.
{/* Sucursales */}
Sucursales
{NOGO.branches.map((b, i) => (
))}
);
}
/* ============================ CATÁLOGO ============================ */
function CatalogScreen({ openProduct, openFilters, filters }) {
const NOGO = window.NOGO;
let list = NOGO.products;
if (filters.use) list = list.filter((p) => p.use === filters.use);
if (filters.colorFam) list = list.filter((p) => p.colors.includes(filters.colorFam));
const activeCount = (filters.use ? 1 : 0) + (filters.colorFam ? 1 : 0);
return (
{[["use", "interior", "Interior"], ["use", "exterior", "Exterior"]].map(([k, v, label]) => (
))}
{list.length} productos
{list.length === 0 &&
No hay productos con esos filtros.
}
);
}
/* ============================ FICHA DE PRODUCTO ============================ */
function ProductScreen({ product, go, onAdd }) {
const NOGO = window.NOGO;
const families = product.colors;
const [fam, setFam] = useState(families[0]);
const famColors = NOGO.palette[fam];
const [color, setColor] = useState(famColors[2] || famColors[0]);
const [presId, setPresId] = useState(product.pres[Math.min(1, product.pres.length - 1)]);
const pres = NOGO.presentations.filter((p) => product.pres.includes(p.id));
const price = NOGO.priceFor(product, presId);
const stock = NOGO.stockFor(product, presId);
const totalColors = families.reduce((n, f) => n + NOGO.palette[f].length, 0);
const tech = [
{ icon: "layers", label: "Rendimiento", value: `${product.rendimiento} m²/L por mano` },
{ icon: "brush", label: "Manos sugeridas", value: `${product.manos}` },
{ icon: "drop", label: "Dilución", value: product.dilucion },
{ icon: "clock", label: "Secado", value: product.secado },
{ icon: "brush", label: "Aplicación", value: product.aplicacion.join(" · ") },
];
return (
{/* Hero con la lata del color elegido */}
{product.use === "exterior" ? "Exterior" : "Interior"}
{product.featured && Más vendido}
{product.name}
{product.tagline}
Envío gratis en Chivilcoy
{/* Presentación */}
Presentación
Precio según tamaño
{/* Color */}
Color · {color.name}
{totalColors} colores
{families.map((f) => (
))}
{/* Datos técnicos */}
Datos técnicos
{tech.map((t, i) => (
{t.label}
{t.value}
))}
{/* CTA fijo: dispara el bot */}
);
}
Object.assign(window, { HomeScreen, CatalogScreen, ProductScreen });