fixed logo, fixed product details page image and api

This commit is contained in:
2025-12-09 06:11:50 -05:00
parent 6b0e0334b0
commit 7c2206ffc3
5 changed files with 57 additions and 38 deletions
@@ -17,7 +17,7 @@ type GunbuilderProductFromApi = {
platform: string;
partRole: string;
price: number | null;
mainImageUrl: string | null;
imageUrl: string | null;
buyUrl: string | null;
};
@@ -55,21 +55,20 @@ export default function PartDetailPage() {
// For now, pull the full AR-15 list and find by UUID.
// We can optimize with a dedicated /api/products/{uuid} later.
const url = `${API_BASE_URL}/api/products/gunbuilder?platform=AR-15`;
const url = `${API_BASE_URL}/api/products/gunbuilder/products/${partId}`;
const res = await fetch(url, { signal: controller.signal });
if (!res.ok) {
throw new Error(`Failed to load product (${res.status})`);
}
const data: GunbuilderProductFromApi[] = await res.json();
const found = data.find((p) => p.id === partId) ?? null;
const data: GunbuilderProductFromApi = await res.json();
if (!found) {
if (!data) {
setError("Product not found");
}
setProduct(found);
setProduct(data);
} catch (err: any) {
if (err.name === "AbortError") return;
setError(err.message ?? "Failed to load product");
@@ -77,7 +76,7 @@ export default function PartDetailPage() {
setLoading(false);
}
}
fetchProduct();
return () => controller.abort();
@@ -187,11 +186,11 @@ export default function PartDetailPage() {
<div className="grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1.3fr)] items-start">
{/* Left: image + meta */}
<div className="space-y-4">
{product.mainImageUrl && (
{product.imageUrl && (
<div className="overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={product.mainImageUrl}
src={product.imageUrl}
alt={product.name}
className="w-full object-contain max-h-80 bg-zinc-950"
/>