/* --- Panos Melekkis · Collection drawer --- */ const D2 = window.PM_DATA; function CollectionDrawer({ collectionId, onClose, onBook, currency }) { const open = !!collectionId; const collection = open ? D2.collections.find((c) => c.id === collectionId) : null; const drawerRef = React.useRef(null); React.useEffect(() => { if (open) document.body.classList.add("is-locked"); else document.body.classList.remove("is-locked"); return () => document.body.classList.remove("is-locked"); }, [open]); // when collection changes, scroll drawer to top React.useEffect(() => { if (drawerRef.current) drawerRef.current.scrollTop = 0; }, [collectionId]); // Listen for esc React.useEffect(() => { if (!open) return; const onKey = (e) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open, onClose]); return (
); } function ProductCell({ p, currency, onBook }) { const priced = p.priceAED != null; return (
{p.name} {p.sku}
{p.name}
{priced ? ( {window.PM_fmtPrice(p.priceAED, currency)} ) : ( Price on request )}
{priced ? ( Add to bag ) : ( )}
{p.note &&
{p.note}
}
); } window.CollectionDrawer = CollectionDrawer;