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 (

{t("No videos available.","Belum ada video.")}

); } if (activeIndex === null) { return (
{/* Header */}
{t("Lopobya Video", "Lopobya Video")}
{/* Profile Section */}
Lopobya

@lopobya.official

Premium Women's Bags 👜

{feed.length}Videos
12.4KFollowers
102KLikes
{/* Grid Container */}
{feed.map((f, i) => (
setActiveIndex(i)} style={{ aspectRatio:"9/16", background:"#222", position:"relative", cursor:"pointer", overflow:"hidden", transition:"transform 0.2s" }} onMouseEnter={e=>e.currentTarget.style.opacity=0.9} onMouseLeave={e=>e.currentTarget.style.opacity=1}>
))}
); } return (
{feed.map((f, i) => { const prod = products.find(x => String(x.id) === String(f.productId)); return (
); })}
); }; Object.assign(window, { FeedPage });