The Collection feature is the heart of the Monza Motors shopping experience. Visitors can browse every vehicle in the catalog, narrow results using a price range slider (350k) and a model year selector, and click any card to open a full detail page. All catalog data is read from the SupabaseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Jason-AML/MonzaSport-Nextjs/llms.txt
Use this file to discover all available pages before exploring further.
vehiculos table and fetched client-side through React Query, giving the page instant stale-while-revalidate caching without a full page reload.
Collection View
TheCollectionView component is a client component ("use client") that owns the filtering state and delegates rendering to child Card components. On mount, React Query fires a single request to Supabase via getCollections() and caches the result under the "collections" query key.
isLoading is true, a loading indicator is shown. If error is set, an error message is rendered across the full grid width. Once data arrives, it is passed through the active filter before being mapped to Card components.
Filtering
The sidebar exposes two controls that work together to reduce the visible vehicle list:- Price range — A range slider with
min={10000}andmax={350000}. Its value is stored inpricestate (default350000). AuseMemocall recomputesfilteredDatawheneverdataorpricechanges, keeping only vehicles whosepreciois less than or equal to the selected value. - Year — A
<select>element listing 2024, 2023, and 2022 alongside an “All Years” default.
handleClearFilter, which resets the price slider back to its maximum value of 350000, restoring the full catalog.
filteredData is empty after filtering, a “No vehicles found matching your filters” message spans the full grid width so users know the result set is intentionally empty rather than a loading failure.
Vehicle Card
EachCard receives a single data prop — one row from the vehiculos table. The component renders the following fields:
| Field | Usage |
|---|---|
nombre_vehiculo | Card heading and image alt text |
poder_hp | Power badge (HP) |
aceleracion_0_100 | Acceleration badge (seconds) |
torque_nm | Torque badge |
precio | Price displayed in the card footer |
url_img | Vehicle photo (Next.js <Image> with lazy loading) |
id | Href for the detail link: /collection/{id} |
<Image> component with loading="lazy" and a group-hover:scale-110 CSS transition so they zoom in when the user hovers the card. An “In Stock” badge is overlaid on the top-left corner of every card image.
Vehicle Detail Page
Navigating to/collection/[carId] opens a dedicated detail page. The route is a server component (page.js) that:
- Awaits
paramsto readcarIdfrom the URL. - Calls
getCollectionById(carId)to fetch the full vehicle record including joinedfabricasandstoredrelations. - Passes the result as a
vehicleprop to the clientDetailcomponent.
<head> metadata is also generated from the same data fetch using Next.js’s generateMetadata export, so each vehicle page gets a unique <title>, <meta description>, and Open Graph image automatically.
Detail component renders a full-width image gallery on the left and a sticky pricing card with a “Buy Now” button on the right. The technical specifications grid displays every performance field from the database:
| Field | Label |
|---|---|
nombre_vehiculo | Vehicle name (hero heading) |
modelo | Model badge overlay on image |
anio | Model year displayed below the name |
precio | Price in the sticky CTA card |
motor | Engine badge overlay on image + spec grid |
poder_hp | Power (HP) |
aceleracion_0_100 | 0–100 km/h time |
velocidad_maxima | Top speed (km/h) |
torque_nm | Torque (Nm) |
peso_kg | Weight (kg) |
url_img | Hero background image |
fabricas | Joined manufacturer record — plant name, city, and country shown in the dealer info panel |
stored | Joined storage/inventory relation |
Data Services
All Supabase queries for the collection feature live insrc/services/collectionClient.js. The file exports four functions: