/* ------------------------------------------------------------------ * * Product detail page — with configurator (i18n) * ------------------------------------------------------------------ */ function PageProduct({ slug, navigate, onAddToQuote }) { const { t, lang } = useLang(); const { format } = useCurrency(); const { isTrade, applyDiscount, discount } = useTrade(); const products = getProducts(t); const product = products.find((p) => p.id === slug) || products[0]; const [color, setColor] = useState(product.colors[0]); const [qty, setQty] = useState(1); const [toast, setToast] = useState(false); const [shot, setShot] = useState(0); // reset on product change useEffect(() => { setColor(product.colors[0]); setQty(1); setShot(0); }, [product.id]); // keep the selected colour in sync with current language (preserve the selected id) useEffect(() => { setColor((c) => product.colors.find((x) => x.id === c.id) || product.colors[0]); }, [product.id, lang]); const retailTotal = Math.round(product.basePrice * qty); const total = applyDiscount(retailTotal); const gallery = product.gallery && product.gallery.length ? product.gallery : [{ src: product.photo, label: product.id, crop: product.name }]; const current = gallery[Math.min(shot, gallery.length - 1)]; return (
{ e.preventDefault(); navigate("/collection"); }} className="link-u">{t("prod.crumb")} / {product.name}
{gallery.map((g, i) => ( {g.crop} ))}
{current.label} {current.crop}
{gallery.length > 1 && ( )}
{gallery.length > 1 && (
{gallery.map((g, i) => ( ))}
)}
{product.tagline}

{product.name}

{product.desc}

{t("prod.finish")} {color.name}

{product.colors.map((c) => (

{t("prod.qty")} {qty} {qty !== 1 ? t("common.units") : t("common.unit")}

{t("prod.estimate")} {isTrade && {t("trade.tag")} −{Math.round(discount * 100)}%} {isTrade && {format(retailTotal)}} {format(total)}
{t("prod.lead")}
{t("prod.spec")}
    {product.features.map((f) => (
  • {t("prod.spec.feature")} {f}
  • ))}
  • {t("prod.spec.dims")} {product.dim}
  • {t("prod.spec.material")} {t("prod.spec.materialVal")}
  • {t("prod.spec.origin")} {t("prod.spec.originVal")}
  • {t("prod.spec.warranty")} {t("prod.spec.warrantyVal")}
{t("prod.ideal")}
{product.ideal.map((i) => ( {i} ))}
{t("prod.pairs")}
{products.filter((p) => p.id !== product.id).map((p) => ( ))}
); } Object.assign(window, { PageProduct });