"use client";
import Link from "next/link";
type UiPart = {
id: string;
name: string;
brand: string;
platform: string;
partRole: string;
price: number;
imageUrl?: string;
buyUrl?: string;
inStock?: boolean;
};
export default function PartsGrid(props: {
viewMode: "card" | "list";
parts: UiPart[];
buildDetailHref: (p: UiPart) => string;
onAddToBuild?: (p: UiPart) => void;
addLabel?: string;
}) {
const { viewMode, parts, buildDetailHref, onAddToBuild } = props;
const addLabel = props.addLabel ?? "Add to Build";
if (viewMode === "card") {
return (
{parts.map((part) => (
{part.brand} — {part.name}
${part.price.toFixed(2)}
View Details
{onAddToBuild ? (
) : part.buyUrl ? (
Buy
) : (
)}
))}
);
}
// LIST view
return (
<>
{/* Header (DESKTOP ONLY) */}
Part
Brand
Price
Actions
{/* Rows */}
{parts.map((part) => (
{/* Part */}
{/* Brand */}
{part.brand}
{/* Price */}
${part.price.toFixed(2)}
{/* Actions */}
View Details
{onAddToBuild ? (
) : part.buyUrl ? (
Buy
) : (
)}
))}
>
);
}