// Alba Cars — Inventory page (Buy) const { useState: useStateI, useMemo: useMemoI } = React; function InventoryPage({ setRoute, setVehicleId }) { const [brand, setBrand] = useStateI('All'); const [body, setBody] = useStateI('All'); const [yearMin, setYearMin] = useStateI(2020); const [priceMax, setPriceMax] = useStateI(1500000); const [sort, setSort] = useStateI('newest'); const [includesPOA, setIncludesPOA] = useStateI(true); const [query, setQuery] = useStateI(''); const [view, setView] = useStateI('grid'); const filtered = useMemoI(() => { let out = VEHICLES.filter(v => { if (brand !== 'All' && v.make !== brand) return false; if (body !== 'All' && v.body !== body) return false; if (v.year < yearMin) return false; if (v.price != null && v.price > priceMax) return false; if (v.price == null && !includesPOA) return false; if (query && !`${v.make} ${v.model} ${v.variant}`.toLowerCase().includes(query.toLowerCase())) return false; return true; }); out.sort((a, b) => { if (sort === 'newest') return b.year - a.year; if (sort === 'oldest') return a.year - b.year; if (sort === 'price-low') return (a.price ?? 9e9) - (b.price ?? 9e9); if (sort === 'price-high') return (b.price ?? 0) - (a.price ?? 0); if (sort === 'mileage') return a.mileage - b.mileage; return 0; }); return out; }, [brand, body, yearMin, priceMax, sort, includesPOA, query]); return (
{/* Header strip */}
Live · 212 cars in stock

Inventory — {filtered.length} of {VEHICLES.length} shown

Demo prices for illustration. Live build pulls real prices and full image sets from the inventory feed.

1100 ? '280px 1fr' : '1fr', gap: 40 }}> {/* Filter sidebar */} {/* Results */}
{filtered.length === 0 ? (

No cars match those filters.

Try widening the price or year range.

) : view === 'grid' ? (
1400 ? 'repeat(3, 1fr)' : window.innerWidth > 700 ? 'repeat(2, 1fr)' : '1fr', gap: 22, }}> {filtered.map(v => ( { setVehicleId(v.id); setRoute('vehicle'); window.scrollTo({top:0}); }} /> ))}
) : (
{filtered.map(v => ( { setVehicleId(v.id); setRoute('vehicle'); window.scrollTo({top:0}); }} /> ))}
)}
); } function viewBtn(active) { return { padding: '8px 16px', borderRadius: 999, border: '1px solid var(--border)', background: active ? 'var(--ink)' : 'transparent', color: active ? '#fff' : 'var(--text)', fontFamily: 'var(--f-display)', fontSize: 12, fontWeight: 500, letterSpacing: '0.06em', textTransform: 'uppercase', cursor: 'pointer', }; } function FilterGroup({ label, children }) { return (
{label}
{children}
); } function FilterChips({ options, value, onChange }) { return (
{options.map(opt => ( ))}
); } function SliderField({ min, max, step, value, onChange, display }) { return (
{display}
onChange(+e.target.value)} style={{ width: '100%', appearance: 'none', height: 4, borderRadius: 2, background: `linear-gradient(to right, var(--alba-red) 0%, var(--alba-red) ${((value-min)/(max-min))*100}%, var(--border) ${((value-min)/(max-min))*100}%, var(--border) 100%)`, }} />
); } function VehicleRow({ v, onClick }) { const isPOA = v.price == null; return (
800 ? '320px 1fr auto' : '1fr', gap: 24, padding: 20, alignItems: 'center', background: 'var(--surface)', border: '1px solid var(--border)', borderRadius: 12, cursor: 'pointer', transition: 'all 0.2s', }} onMouseEnter={(e) => e.currentTarget.style.borderColor = 'var(--text)'} onMouseLeave={(e) => e.currentTarget.style.borderColor = 'var(--border)'} >
{v.year} · {v.make} · {v.stockId}

{v.model} {v.variant}

{[ ['Mileage', fmtMileage(v.mileage)], ['Engine', v.engine], ['Trans', v.trans], ['Drive', v.drive], ['Body', v.body], ].map(([k, val]) => (
{k}
{val}
))}
{isPOA ? 'Inquire' : 'Demo price'}
{fmtAED(v.price)}
View
); } Object.assign(window, { InventoryPage });