"use client"; import Link from "next/link"; import { Plus } from "lucide-react"; type UiPart = { id: string; name: string; brand: string; caliber?: 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) */}
Image Part Caliber Price Actions
{/* Rows */}
{parts.map((part) => (
{/* Image */}
{part.imageUrl ? ( // eslint-disable-next-line @next/next/no-img-element ) : (
)}
{/* Part */}
{part.name} {/* Dont think we need Brand in the grid */} {/*
{part.brand} {part.caliber ? ( • {part.caliber} ) : null}
*/}
{/* Caliber (desktop) */}
{part.caliber ?? "—"}
{/* Price */}
${part.price.toFixed(2)}
{/* Actions */}
{onAddToBuild ? ( ) : part.buyUrl ? ( Buy ) : ( )}
))}
); }