// 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 */}
{/* 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 */}
{qty}
{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;