/* global React, Icon, VehicleCard, CV_INVENTORY, CV_BRANDS */ const { useState, useEffect, useMemo } = React; // ───────────────────────────────────────────────────────────────────────────── // INVENTORY // ───────────────────────────────────────────────────────────────────────────── function InventoryPage({ setPage, openVehicle, initialFilter }) { const [query, setQuery] = useState(""); const [brand, setBrand] = useState("All"); const [body, setBody] = useState(initialFilter && ["SUV","Coupe","Sedan","Convertible","Hypercar","Classic"].includes(initialFilter) ? initialFilter : "All"); const [tag, setTag] = useState(initialFilter && ["Sport","Luxury","Classic","Halo","New"].includes(initialFilter) ? initialFilter : "All"); const [yearRange, setYearRange] = useState("All"); const [sort, setSort] = useState("featured"); const [view, setView] = useState("grid"); // grid | row const bodies = ["All", "Hypercar", "Coupe", "Convertible", "Sedan", "SUV", "Classic"]; const tags = ["All", "Halo", "Sport", "Luxury", "Classic", "New"]; const brands = ["All", ...new Set(CV_INVENTORY.map(v => v.make))]; const filtered = useMemo(() => { let out = CV_INVENTORY.slice(); if (query) { const q = query.toLowerCase(); out = out.filter(v => `${v.year} ${v.make} ${v.model}`.toLowerCase().includes(q)); } if (brand !== "All") out = out.filter(v => v.make === brand); if (body !== "All") out = out.filter(v => v.body === body); if (tag !== "All") out = out.filter(v => v.tag === tag); if (yearRange !== "All") { const [lo, hi] = ({ "2024+": [2024, 9999], "2020+": [2020, 9999], "2015–2019": [2015, 2019], "Pre-2015": [0, 2014] })[yearRange]; out = out.filter(v => v.year >= lo && v.year <= hi); } if (sort === "yearDesc") out.sort((a,b) => b.year - a.year); if (sort === "yearAsc") out.sort((a,b) => a.year - b.year); if (sort === "az") out.sort((a,b) => a.make.localeCompare(b.make)); return out; }, [query, brand, body, tag, yearRange, sort]); const clearAll = () => { setQuery(""); setBrand("All"); setBody("All"); setTag("All"); setYearRange("All"); setSort("featured"); }; const active = [ query && ["search", `"${query}"`], brand !== "All" && ["brand", brand], body !== "All" && ["body", body], tag !== "All" && ["tag", tag], yearRange !== "All" && ["year", yearRange] ].filter(Boolean); return (
Inventory · {filtered.length} of {CV_INVENTORY.length}

Cars currently on the floor.

Demo inventory drawn from the public showroom listing — production wiring is per-car SSG/ISR over the client's live feed, so each vehicle becomes its own indexable page.

setQuery(e.target.value)} /> {query && }
{active.length > 0 && (
{active.map(([k, label]) => ( {label} ))}
)} {filtered.length === 0 ? (

No cars match — yet.

Inventory rotates quickly. WhatsApp the showroom and we'll flag the next arrival that fits your brief.

WhatsApp the desk
) : view === "grid" ? (
{filtered.map(v => )}
) : (
{filtered.map(v => )}
)}
); } function InventoryRow({ v, onOpen }) { return ( ); } window.InventoryPage = InventoryPage;