// Product detail page const ProductPage = ({product, addToCart, isReseller, onSignup, setRoute, openProduct}) => { const [qty, setQty] = React.useState(1); const [added, setAdded] = React.useState(false); // Fallback to first product if none passed const p = product || PRODUCTS[0]; const detail = PRODUCT_DETAILS[p.id] || {}; const hueColor = p.hue === "cyan" ? "var(--color-cyan)" : p.hue === "magenta" ? "var(--color-magenta)" : "var(--color-pink)"; const hueRgb = p.hue === "cyan" ? "120,214,241" : p.hue === "magenta" ? "255,45,180" : "236,142,190"; const wsPrice = (p.price * 0.55).toFixed(2); const related = PRODUCTS.filter(x => x.category === p.category && x.id !== p.id).slice(0, 3); const handleAdd = () => { if (!addToCart) { onSignup && onSignup(); return; } for (let i = 0; i < qty; i++) addToCart(p); setAdded(true); setTimeout(() => setAdded(false), 2000); }; return ( <> {/* Back nav */} { setRoute("shop"); window.scrollTo({top:0,behavior:"instant"}); }} style={{ background:"transparent", border:0, cursor:"pointer", display:"flex", alignItems:"center", gap:8, fontFamily:"var(--font-mono)", fontSize:11, letterSpacing:".2em", textTransform:"uppercase", color:"rgba(227,240,247,.55)", }}> Back to Shop {/* Hero / Main product */} {/* Left: Visual */} {p.badge && ( {p.badge} )} {isReseller && ( WHOLESALE )} {/* Hardware illustration — larger */} {p.spec} {/* Right: Info */} {p.type} {p.name} {detail.description || p.spec} {/* Pricing */} {isReseller ? ( Wholesale Price ${wsPrice} MSRP ${p.price.toFixed(2)} ) : ( Price per unit ${p.price.toFixed(2)} )} {/* Qty + Add to cart */} setQty(q => Math.max(1, q - 1))} style={{ width:44, height:44, background:"transparent", border:0, cursor:"pointer", color:"var(--color-fg)", display:"flex", alignItems:"center", justifyContent:"center", }} > {qty} setQty(q => q + 1)} style={{ width:44, height:44, background:"transparent", border:0, cursor:"pointer", color:"var(--color-fg)", display:"flex", alignItems:"center", justifyContent:"center", }} > {added ? ( <> Added> ) : ( <> Add to Cart> )} {isReseller && ( Wholesale MOQ · 1,000 units per SKU )} {/* Spec rows */} {detail.features && ( Specifications {detail.features.map(f => ( {f} ))} )} {/* Technical spec table */} Tech Spec. {[ ["SKU Name", p.name], ["Type", p.type], ["Fill Capacity", p.spec.split("·")[0]?.trim()], ["Connection", detail.connection || "—"], ["Coil Type", detail.coil || "Ceramic"], ["Resistance", detail.resistance || "—"], ["Dimensions", detail.dimensions || "—"], ["Battery", p.spec.includes("mAh") ? p.spec.split("·").find(s => s.includes("mAh"))?.trim() : "N/A"], ["Category", p.category], ["COA Included", "Yes — every batch"], ["Min. Order", "1,000 units (wholesale)"], ].map(([k, v], i, arr) => ( {k} {v} ))} {/* Related products */} {related.length > 0 && ( More in {p.category} Related. {related.map(rp => ( addToCart && addToCart(rp)} isReseller={isReseller} onOpen={() => openProduct ? openProduct(rp) : undefined} /> ))} )} > ); }; window.ProductPage = ProductPage;
{detail.description || p.spec}