From c01aabb00317efdd024bf259c0117830560c9cbb Mon Sep 17 00:00:00 2001
From: Sean
Date: Mon, 22 Dec 2025 17:31:04 -0500
Subject: [PATCH] cleaned up product details page. added a link on builder to
the selected product details page
---
app/(app)/(builder)/builder/page.tsx | 38 ++-
.../[partRole]/[productSlug]/page.tsx | 268 +++++++++++-------
2 files changed, 202 insertions(+), 104 deletions(-)
diff --git a/app/(app)/(builder)/builder/page.tsx b/app/(app)/(builder)/builder/page.tsx
index 84203cf..6288fe6 100644
--- a/app/(app)/(builder)/builder/page.tsx
+++ b/app/(app)/(builder)/builder/page.tsx
@@ -735,7 +735,9 @@ export default function GunbuilderPage() {
const payload = JSON.stringify(build);
const encoded = window.btoa(payload);
const origin = window.location?.origin ?? "";
- const url = `${origin}/builder/build?build=${encodeURIComponent(encoded)}`;
+ const url = `${origin}/builder/build?build=${encodeURIComponent(
+ encoded
+ )}`;
setShareUrl(url);
} catch {
setShareUrl("");
@@ -1024,7 +1026,9 @@ export default function GunbuilderPage() {
}}
disabled={selectedParts.length === 0}
className={`w-full sm:w-auto rounded-md border border-zinc-700 bg-zinc-900/50 px-3 py-2 text-sm font-medium text-zinc-300 hover:bg-zinc-800 hover:border-zinc-600 transition-colors ${
- selectedParts.length === 0 ? "opacity-40 cursor-not-allowed" : ""
+ selectedParts.length === 0
+ ? "opacity-40 cursor-not-allowed"
+ : ""
}`}
>
Clear Build
@@ -1212,8 +1216,9 @@ export default function GunbuilderPage() {
const selectedPartId = build[category.id];
const selectedPart = selectedPartId
- ? categoryParts.find((p) => p.id === selectedPartId) ??
- parts.find((p) => p.id === selectedPartId)
+ ? categoryParts.find(
+ (p) => p.id === selectedPartId
+ ) ?? parts.find((p) => p.id === selectedPartId)
: undefined;
const hasParts = categoryParts.length > 0;
@@ -1232,7 +1237,24 @@ export default function GunbuilderPage() {
{selectedPart ? (
<>
- {selectedPart.name}
+
+ {selectedPart.name}
+ {" "}
{/* Overlap chips help explain conflicts / dependencies */}
@@ -1317,7 +1339,9 @@ export default function GunbuilderPage() {
>
) : hasParts ? (
-
- {/* Platform switch (updates NEW route) */}
-
-
-
-
@@ -414,18 +456,25 @@ export default function ProductDetailsPage() {
) : (
- {/* Left: image + core actions */}
+ {/* Left */}
{imageUrl ? (
- // eslint-disable-next-line @next/next/no-img-element
-

+
) : (
No image
@@ -439,12 +488,12 @@ export default function ProductDetailsPage() {
- {product.inStock === false ? "Out of stock" : "In stock"}
+ {stockValue === false ? "Out of stock" : "In stock"}
@@ -467,20 +516,18 @@ export default function ProductDetailsPage() {
: "bg-amber-400 text-black hover:bg-amber-300"
}`}
>
- {isSelected ? "Remove" : "Add"}
+ {isSelected ? "Remove" : "Add to Build"}
- {/* Pricing history placeholder */}
+ {/* Price history placeholder */}
Price History
-
- placeholder
-
+ placeholder
Pricing graph will go here
@@ -492,7 +539,7 @@ export default function ProductDetailsPage() {
- {/* Right: details + offers */}
+ {/* Right */}
{/* Product meta */}
@@ -532,7 +579,7 @@ export default function ProductDetailsPage() {
Current price
- {formatPrice(product.price)}
+ {formatPrice(currentPrice)}
@@ -560,7 +607,11 @@ export default function ProductDetailsPage() {
Merchant Offers
- {offers.length ? `${offers.length} offers` : "no offers"}
+ {offersLoading
+ ? "loading…"
+ : offers.length
+ ? `${offers.length} offers`
+ : "no offers"}
@@ -578,16 +629,15 @@ export default function ProductDetailsPage() {
{offers.map((o, idx) => (
- {" "}
|
- {o.merchantName ?? "Merchant"}
+ {merchantLabel(o)}
{isBestOffer(o) && (
@@ -607,9 +657,7 @@ export default function ProductDetailsPage() {
)}
|
- {o.price != null
- ? `$${o.price.toFixed(2)}`
- : "—"}
+ {o.price != null ? `$${o.price.toFixed(2)}` : "—"}
|
{o.buyUrl ? (
@@ -622,9 +670,7 @@ export default function ProductDetailsPage() {
Buy
) : (
-
- —
-
+ —
)}
|
@@ -639,7 +685,7 @@ export default function ProductDetailsPage() {
)}
- {/* Best Offer CTA (uses sorted offers[0]) */}
+ {/* Best Offer CTA */}
{bestOffer?.buyUrl ? (
) : null}
@@ -656,21 +702,49 @@ export default function ProductDetailsPage() {
{/* Footer tips */}
-
+ {/*
Tip: Add this part, then go back and compare alternates.
-
-
+ */}
+ {/*
Canonical route:{" "}
/parts/p/{platform}/{partRoleParam}/{productSlug}
-
+ */}
)}
+
+ {/* Image modal */}
+ {isImageOpen && imageUrl ? (
+ setIsImageOpen(false)}
+ >
+
e.stopPropagation()}
+ >
+
+
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+
+ ) : null}
);
-}
+}
\ No newline at end of file