MCPcopy
hub / github.com/adrianhajdin/project_next13_car_showcase / Home

Function Home

app/page.tsx:6–58  ·  view source on GitHub ↗
({ searchParams }: HomeProps)

Source from the content-addressed store, hash-verified

4import { CarCard, ShowMore, SearchBar, CustomFilter, Hero } from "@components";
5
6export default async function Home({ searchParams }: HomeProps) {
7 const allCars = await fetchCars({
8 manufacturer: searchParams.manufacturer || "",
9 year: searchParams.year || 2022,
10 fuel: searchParams.fuel || "",
11 limit: searchParams.limit || 10,
12 model: searchParams.model || "",
13 });
14
15 const isDataEmpty = !Array.isArray(allCars) || allCars.length < 1 || !allCars;
16
17 return (
18 <main className='overflow-hidden'>
19 <Hero />
20
21 <div className='mt-12 padding-x padding-y max-width' id='discover'>
22 <div className='home__text-container'>
23 <h1 className='text-4xl font-extrabold'>Car Catalogue</h1>
24 <p>Explore out cars you might like</p>
25 </div>
26
27 <div className='home__filters'>
28 <SearchBar />
29
30 <div className='home__filter-container'>
31 <CustomFilter title='fuel' options={fuels} />
32 <CustomFilter title='year' options={yearsOfProduction} />
33 </div>
34 </div>
35
36 {!isDataEmpty ? (
37 <section>
38 <div className='home__cars-wrapper'>
39 {allCars?.map((car) => (
40 <CarCard car={car} />
41 ))}
42 </div>
43
44 <ShowMore
45 pageNumber={(searchParams.limit || 10) / 10}
46 isNext={(searchParams.limit || 10) > allCars.length}
47 />
48 </section>
49 ) : (
50 <div className='home__error-container'>
51 <h2 className='text-black text-xl font-bold'>Oops, no results</h2>
52 <p>{allCars?.message}</p>
53 </div>
54 )}
55 </div>
56 </main>
57 );
58}

Callers

nothing calls this directly

Calls 1

fetchCarsFunction · 0.85

Tested by

no test coverage detected