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 }) => (
{heroSubtitle}
{spotConf.blurb || spotlight.description || t("A timeless piece, crafted to last.","Pilihan abadi yang dibuat untuk menemani setiap langkahmu.")}
"{r.text}"
{nlSubtitle}