/* inventory.jsx — inventory filtering + grid */ const { useState: useStateI, useMemo: useMemoI } = React; function Inventory({ onSelect, onEnquire, initialFilter = {} }) { const [brand, setBrand] = useStateI(initialFilter.brand || "All"); const [body, setBody] = useStateI(initialFilter.body || "All"); const [status, setStatus] = useStateI(initialFilter.status || "all"); const [sort, setSort] = useStateI("newest"); const [view, setView] = useStateI("grid"); const filtered = useMemoI(() => { let r = INVENTORY.filter((v) => { if (brand !== "All" && v.brand !== brand) return false; if (body !== "All" && v.body !== body) return false; if (status === "available" && v.status !== "available") return false; if (status === "sold" && v.status !== "sold") return false; return true; }); if (sort === "newest") r = r.sort((a, b) => b.year - a.year); if (sort === "oldest") r = r.sort((a, b) => a.year - b.year); if (sort === "az") r = r.sort((a, b) => a.brand.localeCompare(b.brand) || a.model.localeCompare(b.model)); return r; }, [brand, body, status, sort]); const counts = useMemoI(() => { const all = INVENTORY.length; const avail = INVENTORY.filter((v) => v.status === "available").length; const sold = INVENTORY.filter((v) => v.status === "sold").length; return { all, avail, sold }; }, []); const brandCounts = useMemoI(() => { const c = {}; INVENTORY.forEach((v) => { c[v.brand] = (c[v.brand] || 0) + 1; }); return c; }, []); return (
{/* Page header */}
Inventory · Updated daily

What's in
the showroom.

Filter by marque, bodystyle and status. Prices are private — request on the car you want to see.

Demo inventory — replaced by feed in production {filtered.length} of {counts.all} shown
{/* Filter bar */}
{/* Status segmented */}
{[ ["all", "All", counts.all], ["available", "Available", counts.avail], ["sold", "Sold", counts.sold], ].map(([k, l, n]) => ( ))}
{/* Brand select */} {(brand !== "All" || body !== "All" || status !== "all") && ( )}
{/* Grid */}
{filtered.length === 0 ? ( ) : view === "grid" ? (
{filtered.map((v) => )}
) : ( )}
{/* Bottom CTA */}
Don't see it?

Commission us to find your next car.

); } function ListView({ vehicles, onSelect }) { return (
{vehicles.map((v) => ( ))}
); } function EmptyState({ onEnquire }) { return (
No matches in current stock

New arrivals weekly.
Register your interest.

We'll notify you privately when something matching your filters lands at the showroom.

); } Object.assign(window, { Inventory });