"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; // NEW: optional Add-to-Build behavior 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 {/* NEW: Add to Build (preferred primary action if provided) */} {onAddToBuild ? ( ) : part.buyUrl ? ( Buy ) : ( )}
))}
); } // LIST view return ( <>
Part Brand Price Actions
{parts.map((part) => (
{part.name}
{part.brand}
${part.price.toFixed(2)}
View Details {onAddToBuild ? ( ) : part.buyUrl ? ( Buy ) : ( )}
))}
); }