// E-shop chrome: header, mobile drawer, slide-in cart, search overlay, footer.
(function () {
if (typeof React === "undefined") return;
const DS = window.VElaStvNajmanDesignSystem_bc3fc2;
const { Button, IconButton, Input } = DS;
const Icon = window.VNIcon;
// Sesterský web — medová větev značky (rodinný e-shop s medem a medovinou).
const HONEY_URL = "https://www.vcelarstvinajman.cz";
const NAV = [
{ id: "category", label: "Nabídka" },
{ id: "blog", label: "Blog" },
{ id: "about", label: "O chovu" },
{ id: "contact", label: "Kontakt" },
{ id: "med", label: "Med", external: true, href: HONEY_URL },
];
function Logo({ onClick, footer }) {
return (
{ e.preventDefault(); onClick && onClick(); }} href="#">
Včelařství Najman
Chov matek · Hostivice
);
}
function ProfileMenu({ user, go, onLogout, onClose }) {
return (
{user.firstName} {user.lastName}
{user.email}
);
}
function HeaderProfile({ user, go, onProfile, onLogout }) {
const [open, setOpen] = React.useState(false);
const ref = React.useRef(null);
React.useEffect(() => {
if (!open) return;
const onDoc = (e) => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); };
const onKey = (e) => { if (e.key === "Escape") setOpen(false); };
document.addEventListener("mousedown", onDoc);
window.addEventListener("keydown", onKey);
return () => { document.removeEventListener("mousedown", onDoc); window.removeEventListener("keydown", onKey); };
}, [open]);
if (!user) {
return (
);
}
const initials = ((user.firstName[0] || "") + (user.lastName[0] || "")).toUpperCase();
return (
{open &&
setOpen(false)} />}
);
}
function Header({ go, current, currentArg, cartCount, cartPulse, onCart, onMenu, user, onProfile, onLogout }) {
const [scrolled, setScrolled] = React.useState(false);
const [bump, setBump] = React.useState(false);
React.useEffect(() => {
if (!cartPulse) return;
setBump(true);
const t = setTimeout(() => setBump(false), 360);
return () => clearTimeout(t);
}, [cartPulse]);
React.useEffect(() => {
const sc = document.querySelector(".kit-scrollroot") || window;
const t = sc === window ? document.documentElement : sc;
const fn = () => setScrolled((t.scrollTop || window.scrollY) > 8);
sc.addEventListener("scroll", fn, { passive: true });
return () => sc.removeEventListener("scroll", fn);
}, []);
return (
go("home")} />
);
}
function Drawer({ open, onClose, go }) {
return (
<>
>
);
}
function CartLine({ item, onQty, onRemove }) {
const { Photo, QuantityStepper } = DS;
return (
{item.name}
{item.region} · {item.weight}
{item.preorder &&
Předobjednávka — odešleme po naskladnění ({item.preorder})
}
onQty(item.id, v)} />
{item.price * item.qty} Kč
);
}
function Cart({ open, onClose, items, onQty, onRemove, onCheckout, onAdd, peek, onClear }) {
const { Photo } = DS;
const D = window.SHOP_DATA;
const total = items.reduce((s, i) => s + i.price * i.qty, 0);
const count = items.reduce((s, i) => s + i.qty, 0);
const freeAt = 4;
const left = Math.max(0, freeAt - count);
const pct = Math.min(100, (count / freeAt) * 100);
// "Mohlo by se hodit" — nabízí produkty, které v košíku ještě NEJSOU (podle
// druhu, napříč variantami — porovnání přes název) a jsou skladem, aby šly
// rovnou dokoupit. Řazeno dle oblíbenosti, max 3. Sekce zmizí, až jsou
// v košíku všechny dostupné druhy z nabídky.
const cartNames = new Set(items.map(i => i.name));
const cartIds = new Set(items.map(i => i.id));
const inCart = (p) => cartNames.has(p.name) || cartIds.has(p.id) || items.some(i => String(i.id).indexOf(p.id + "-") === 0);
const recs = (D && D.products)
? D.products.filter(p => !inCart(p) && p.stock !== "out").sort((a,b)=>b.reviews-a.reviews).slice(0,3)
: [];
return (
<>
>
);
}
function Footer({ go }) {
// Footer links to homepage sections: navigate home, then scroll to the anchor.
const goHomeTo = (id) => {
go("home");
setTimeout(() => {
const el = document.getElementById(id);
if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 80, behavior: "smooth" });
}, 80);
};
return (
);
}
Object.assign(window, { VNHeader: Header, VNDrawer: Drawer, VNCart: Cart, VNFooter: Footer, VNLogo: Logo, VN_NAV: NAV });
})();