const HomePage = ({ setPage, setSelectedProduct, onAddToCart, lang, heroSettings, homeSettings, products, productsReady }) => { const t = (en, id) => lang === "id" ? id : en; const ACCENT = "#a9744f"; const list = (Array.isArray(products) && products.length) ? products : (window.PRODUCTS || []); // ── Settings + default ─────────────────────────────────── const hero = heroSettings || {}; const home = homeSettings || {}; const fallbackImg = "uploads/product_images-1777527711871.png"; const heroTitle = hero.title || "Bawa ceritamu ke mana saja."; const heroAccent = hero.accent || "ceritamu"; const heroSubtitle = hero.subtitle || "Tas wanita premium yang dibuat dengan tangan di Indonesia — untuk mereka yang bergerak dengan niat dan gaya."; const heroBtn1 = hero.btnPrimary || hero.btnText || "Belanja Sekarang"; const heroBtn2 = hero.btnSecondary || "Lihat Koleksi"; const heroImg = hero.image || fallbackImg; const heroPill = hero.pillText || "Koleksi 2026 telah tiba"; const heroStats = Array.isArray(hero.stats) && hero.stats.length ? hero.stats : [ { value:"4.9★", label:t("1,200+ reviews","1.200+ ulasan") }, { value:"10K+", label:t("Customers","Pelanggan") }, { value:"100%", label:t("Authentic","Bahan asli") }, ]; const showMarquee = home.showMarquee !== false; const showCategories = home.showCategories !== false; const showBestsellers = home.showBestsellers !== false; const showSpotlight = home.spotlight ? home.spotlight.show !== false : true; const showTestimonials= home.showTestimonials!== false; const showNewsletter = home.newsletter ? home.newsletter.show !== false : true; const marqueeItems = (Array.isArray(home.marquee) && home.marquee.length) ? home.marquee : [t("Free Shipping","Gratis Ongkir"), t("Authentic Materials","Bahan Asli"), t("Made in Indonesia","Buatan Indonesia"), t("Easy Returns","Mudah Dikembalikan"), t("7-Day Guarantee","Garansi 7 Hari")]; const testimonials = (Array.isArray(home.testimonials) && home.testimonials.length) ? home.testimonials : [ { name:"Saraswati A.", city:"Jakarta", text:"Bahannya beneran premium, jahitannya rapi. Dipakai ke kantor maupun hangout sama-sama cocok. Worth it banget!" }, { name:"Rina N.", city:"Bandung", text:"Packing aman, sampai cepat, dan tasnya lebih bagus dari foto. Udah beli 3 kali dan nggak pernah kecewa." }, { name:"Dewi P.", city:"Surabaya", text:"Suka banget sama desainnya yang simpel tapi elegan. CS-nya juga ramah dan fast respon. Recommended!" }, ]; const nl = home.newsletter || {}; const nlTitle = nl.title || t("Be the first to know","Jadilah yang pertama tahu"); const nlSubtitle = nl.subtitle || t("Sign up & get 10% off your first order.","Daftar newsletter & dapatkan diskon 10% untuk pembelian pertamamu."); // ── Derived product lists ──────────────────────────────── const featured = (() => { const f = list.filter(p => p.badge === "NEW" || p.badge === "BEST SELLER").slice(0,4); return f.length ? f : list.slice(0,4); })(); const bestsellers = list.slice(0,4); // Produk di kartu hero melayang — bisa dipilih admin (hero.featuredProductId), default produk unggulan pertama const heroCard = (() => { if (hero.featuredProductId) { const f = list.find(p => String(p.id) === String(hero.featuredProductId)); if (f) return f; } return featured[0] || null; })(); const spotConf = home.spotlight || {}; const spotlight = (() => { if (spotConf.productId) { const f = list.find(p => String(p.id) === String(spotConf.productId)); if (f) return f; } return list.find(p => p.badge === "BEST SELLER") || list[0] || null; })(); const spotImg = spotlight ? ((Array.isArray(spotlight.images) && spotlight.images[0]) || spotlight.image || fallbackImg) : fallbackImg; const categories = [ { id:"tote", label:t("Tote Bag","Tote Bag") }, { id:"shoulder", label:t("Shoulder Bag","Shoulder Bag") }, { id:"sling", label:t("Sling Bag","Sling Bag") }, { id:"handbag", label:t("Hand Bag","Hand Bag") }, { id:"pouch", label:t("Pouch","Pouch") }, { id:"charm", label:t("Charm","Charm") }, ].map(c => { const inCat = list.filter(p => p.category === c.id); const im = inCat[0] ? ((Array.isArray(inCat[0].images) && inCat[0].images[0]) || inCat[0].image) : null; return { ...c, count:inCat.length, img: im || fallbackImg }; }).filter(c => c.count > 0).slice(0,5); // ── Reveal on scroll ───────────────────────────────────── React.useEffect(() => { const els = document.querySelectorAll(".lh-reveal:not(.in)"); const io = new IntersectionObserver((entries) => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add("in"); io.unobserve(e.target); } }); }, { threshold:0.12 }); els.forEach(el => io.observe(el)); return () => io.disconnect(); }, [productsReady, list.length]); // ── Styles ─────────────────────────────────────────────── const wrap = { maxWidth:1200, margin:"0 auto", padding:"0 24px" }; const sec = { padding:"140px 0 88px" }; const secWrap = { maxWidth:1200, margin:"0 auto", padding:"140px 24px 88px" }; const kicker = { fontFamily:"'Inter',sans-serif", fontSize:12, fontWeight:600, color:ACCENT, letterSpacing:"0.14em", textTransform:"uppercase", marginBottom:16 }; const h2style = { fontFamily:"'Fraunces',serif", fontSize:"clamp(32px,4.3vw,54px)", fontWeight:400, letterSpacing:"-0.01em", lineHeight:1.05, color:"#1d1d1f", margin:0 }; const viewAll = { fontFamily:"'Inter',sans-serif", fontSize:14, fontWeight:600, color:"#1d1d1f", cursor:"pointer", whiteSpace:"nowrap" }; const btnPrimary = { fontFamily:"'Inter',sans-serif", fontSize:15, fontWeight:600, padding:"15px 30px", borderRadius:30, cursor:"pointer", border:"none", background:"#1d1d1f", color:"#fff", transition:"transform 0.2s, box-shadow 0.2s" }; const btnGhost = { fontFamily:"'Inter',sans-serif", fontSize:15, fontWeight:600, padding:"15px 30px", borderRadius:30, cursor:"pointer", background:"#fff", color:"#1d1d1f", border:"1px solid #ececf0" }; const SectionHead = ({ k, title, withView }) => (
{k}

{title}

{withView && setPage("catalog")}>{t("View all","Lihat semua")} →}
); const renderTitle = () => { if (heroAccent && heroTitle.includes(heroAccent)) { const i = heroTitle.indexOf(heroAccent); return (<>{heroTitle.slice(0,i)}{heroAccent}{heroTitle.slice(i+heroAccent.length)}); } return heroTitle; }; return (
{/* ── HERO ── */}
{t("New","Baru")}{heroPill}

{renderTitle()}

{heroSubtitle}

{heroStats.map((s,i) => (
{s.value} {s.label}
))}
{heroCard && (
{ setSelectedProduct(heroCard); setPage("product"); }} style={{ position:"absolute", left:-18, bottom:54, display:"flex", alignItems:"center", gap:12, cursor:"pointer", background:"rgba(255,255,255,0.85)", backdropFilter:"blur(12px)", border:"1px solid rgba(255,255,255,0.6)", borderRadius:16, boxShadow:"0 18px 50px rgba(20,20,30,0.10)", padding:"12px 16px" }}>
{heroCard.name}
{formatPrice(heroCard.price)}
)}
★★★★★ 4.9 / 5.0
{/* ── MARQUEE ── */} {showMarquee && (
{[...marqueeItems, ...marqueeItems].map((m,i) => ( {m} ))}
)} {/* ── NEW ARRIVALS ── */}
{productsReady ? featured.map(p => {setSelectedProduct(x);setPage("product");}} onAddToCart={onAddToCart} />) : [1,2,3,4].map(i =>
)}
{/* ── SPOTLIGHT ── */} {showSpotlight && spotlight && (
{spotConf.eyebrow || t("★ FEATURED","★ PRODUK UNGGULAN")}

{spotlight.name}

{spotConf.blurb || spotlight.description || t("A timeless piece, crafted to last.","Pilihan abadi yang dibuat untuk menemani setiap langkahmu.")}

{formatPrice(spotlight.price)}
)} {/* ── CATEGORIES ── */} {showCategories && categories.length > 0 && (
{categories.map((c,i) => (
setPage("catalog")} style={{ borderRadius:22, overflow:"hidden", position:"relative", cursor:"pointer", minHeight:160 }} onMouseEnter={e=>{const im=e.currentTarget.querySelector("img"); if(im) im.style.transform="scale(1.06)";}} onMouseLeave={e=>{const im=e.currentTarget.querySelector("img"); if(im) im.style.transform="none";}}> {c.label}
{c.label} {c.count} {t("items","produk")}
))}
)} {/* ── BEST SELLERS ── */} {showBestsellers && (
{productsReady ? bestsellers.map(p => {setSelectedProduct(x);setPage("product");}} onAddToCart={onAddToCart} />) : [1,2,3,4].map(i =>
)}
)} {/* ── TESTIMONIALS ── */} {showTestimonials && (
{t("CUSTOMER REVIEWS","ULASAN PELANGGAN")}

{t("Loved by 10,000+ women","Dicintai 10.000+ wanita")}

{testimonials.map((r,i) => (
★★★★★

"{r.text}"

{(r.name||"?").split(" ").map(w=>w[0]).slice(0,2).join("")}
{r.name} {r.city}
))}
)} {/* ── NEWSLETTER ── */} {showNewsletter && (

{nlTitle}

{nlSubtitle}

{e.preventDefault(); alert(t("Thank you for subscribing!","Terima kasih sudah mendaftar!"));}} style={{ position:"relative", display:"flex", gap:10, maxWidth:440, margin:"0 auto" }}>
)} {/* ── FOOTER ── */}
); }; Object.assign(window, { HomePage });