import { PrismaClient, Restaurant } from "@prisma/client"; import Header from "../components/Header"; import RestaurantCard from "./components/RestaurantCard"; import SearchSideBar from "./components/SearchSideBar"; const prisma = new PrismaClient(); const fetchRestaurantsByCity = (city: string | undefined) => { const select = { id: true, name: true, main_image: true, price: true, cuisine: true, location: true, slug: true } if (!city) return prisma.restaurant.findMany({select}); return prisma.restaurant.findMany({ where: { location: { name: { equals: city.toLowerCase() } } }, select }) } export default async function Search({searchParams}: {searchParams: {city: string}}) { const restaurants = await fetchRestaurantsByCity(searchParams.city) console.log(restaurants) return ( <>
{ restaurants.length ? restaurants.map(restaurant => { return }) :

No restaurants

}
); }