// ====================== TOP BAR ======================
function TopBar() {
const [loc, setLoc] = React.useState("Recife - PE");
const [locOpen, setLocOpen] = React.useState(false);
const left = [
{ icon: IconCompany, label: "Sobre a JGF", href: "Sobre a JGF.html" },
{ icon: IconChat, label: "Atendimento", href: "https://wa.me/" + WHATSAPP_NUMBER, ext: true },
{ icon: IconPhone, label: "Fale conosco", href: "tel:+558131270069" }];
const cities = ["Recife - PE", "Olinda - PE", "Jaboatão - PE", "Caruaru - PE"];
const link = { display: "flex", alignItems: "center", gap: 7, color: "#dfe4ef", fontSize: 12.5, fontWeight: 500, padding: "0 2px", transition: "color .15s" };
return (
);
}
// ====================== SEARCH (input + category dropdown + suggestions) ======================
const SUGGESTIONS = ["Álcool 70% Audax 5L", "Copos descartáveis 200ml", "Café Santa Clara 250g", "Papel toalha interfolha", "Detergente neutro 5L", "Caneta esferográfica azul", "Sabonete líquido", "Pasta suspensa"];
function SearchBar({ onSearch, initialQuery = "" }) {
const [q, setQ] = React.useState(initialQuery);
const [cat, setCat] = React.useState("Todas as categorias");
const [catOpen, setCatOpen] = React.useState(false);
const [focus, setFocus] = React.useState(false);
const [items, setItems] = React.useState([]); // {nome, secao} do catálogo real
const wrap = React.useRef(null);
React.useEffect(() => {
const h = (e) => {if (wrap.current && !wrap.current.contains(e.target)) {setCatOpen(false);setFocus(false);}};
document.addEventListener("mousedown", h);return () => document.removeEventListener("mousedown", h);
}, []);
React.useEffect(() => {
if (window.JGFCatalog && window.JGFCatalog.allItems) {
window.JGFCatalog.allItems().then(setItems).catch(() => setItems([]));
}
}, []);
const norm = (s) => (s || "").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
const nq = norm(q.trim());
const catId = { "Produtos de Copa": "copa", "Produtos de Limpeza": "limpeza", "Materiais de Escritório": "escritorio" }[cat];
const filtered = nq
? items.filter((it) => (!catId || it.secao === catId) && norm(it.nome).startsWith(nq)).slice(0, 8)
: [];
const PAGES = (window.JGFCatalog && window.JGFCatalog.PAGES) || {};
const goItem = (it) => { const page = PAGES[it.secao]; if (page) window.location.href = page + "?q=" + encodeURIComponent(it.nome); else onSearch(it.nome, cat); };
const go = (term) => {onSearch(term || q, cat);setFocus(false);};
const catList = ["Todas as categorias", ...VISIBLE_CATEGORIES.map((c) => c.label)];
return (
{focus && filtered.length > 0 &&
{filtered.map((it) =>
)}
}
);
}
// ====================== MAIN HEADER ======================
function MainHeader({ cartCount, onCart, onSearch, initialQuery = "" }) {
const action = (icon, l1, l2, onClick, badge) =>
;
return (
{action(, "Carrinho", "Meu carrinho", onCart, cartCount)}
);
}
// ====================== CATEGORY NAVBAR + MEGA MENU ======================
function CategoryNav({ onNav, onOffers }) {
const [mega, setMega] = React.useState(false);
const [equip, setEquip] = React.useState(false);
const navRef = React.useRef(null);
React.useEffect(() => {
const h = (e) => {if (navRef.current && !navRef.current.contains(e.target)) setMega(false);};
document.addEventListener("mousedown", h);return () => document.removeEventListener("mousedown", h);
}, []);
const links = [
{ label: "Produtos de Copa", id: "copa" },
{ label: "Produtos de Limpeza", id: "limpeza" },
{ label: "Materiais de Escritório", id: "escritorio" }];
const linkStyle = { color: "#eef1f8", fontSize: 14, fontWeight: 600, padding: "0 4px", display: "flex", alignItems: "center", gap: 5, height: 54, transition: "color .15s" };
return (
{/* TODAS AS CATEGORIAS */}
{links.map((l) =>
l.id === "equipamentos" && setEquip(true)}
onMouseLeave={() => l.id === "equipamentos" && setEquip(false)}>
{l.id === "equipamentos" && equip &&
{EQUIP_SUB.map((s) =>
)}
}
)}
{/* Ação à direita: contato / WhatsApp (substitui o antigo OFERTAS) */}
PEÇA PELO WHATSAPPWHATSAPP
{/* MEGA MENU */}
{mega &&
{VISIBLE_CATEGORIES.map((c) =>
)}
}
);
}
Object.assign(window, { TopBar, MainHeader, CategoryNav, SUGGESTIONS });