const FeedPage = ({ setPage, setSelectedProduct, onAddToCart, lang, feedSettings, products }) => { const t = (en, id) => lang === "id" ? id : en; const feed = Array.isArray(feedSettings) ? feedSettings : []; const [isMuted, setIsMuted] = React.useState(true); const [activeIndex, setActiveIndex] = React.useState(null); const containerRef = React.useRef(null); React.useEffect(() => { if (activeIndex !== null && containerRef.current) { const slideHeight = containerRef.current.clientHeight; containerRef.current.scrollTop = activeIndex * slideHeight; } }, [activeIndex]); React.useEffect(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { const vid = entry.target; if(entry.isIntersecting) { vid.play().catch(e => console.log("Autoplay prevented:", e)); } else { vid.pause(); } }); }, { threshold: 0.6 }); const videos = document.querySelectorAll(".lpb-feed-video"); videos.forEach(v => observer.observe(v)); // Hide default header/footer when in Feed Page const header = document.querySelector(".lpb-header"); const footer = document.querySelector(".lpb-footer"); const wa = document.querySelector(".lpb-wa-float"); if(header) header.style.display = "none"; if(footer) footer.style.display = "none"; if(wa) wa.style.display = "none"; return () => { videos.forEach(v => observer.unobserve(v)); if(header) header.style.display = ""; if(footer) footer.style.display = ""; if(wa) wa.style.display = ""; }; }, [feed, activeIndex]); const handleProductClick = (productId) => { const p = products.find(x => x.id === productId); if(p) { setSelectedProduct(p); setPage("product"); } }; if (feed.length === 0) { return (
Premium Women's Bags 👜