This commit is contained in:
Ste Vaidis 2023-02-17 22:36:46 +02:00
parent 39896a06ed
commit ccfa7771a5

View File

@ -1,3 +1,4 @@
import { PrismaClient } from "@prisma/client";
import Description from "./components/Description"; import Description from "./components/Description";
import Header from "./components/Header"; import Header from "./components/Header";
import Images from "./components/Images"; import Images from "./components/Images";
@ -7,7 +8,42 @@ import RestaurantNavBar from "./components/RestaurantNavBar";
import Reviews from "./components/Reviews"; import Reviews from "./components/Reviews";
import Title from "./components/Title"; import Title from "./components/Title";
export default function RestaurantDetails() { interface Restaurant {
id: number;
name: string;
images: string[];
description: string;
slug: string;
}
const prisma = new PrismaClient();
const fetchRestaurantBySlug = async (slug: string): Promise<Restaurant> => {
const restaurant = await prisma.restaurant.findUnique({
where: {
slug,
},
select: {
id: true,
name: true,
images: true,
description: true,
slug: true,
},
});
if (!restaurant) {
throw new Error()
}
return restaurant;
};
export default async function RestaurantDetails({
params,
}: {
params: { slug: string };
}) {
const restaurant = await fetchRestaurantBySlug(params.slug);
return ( return (
<> <>
<div className="bg-white w-[70%] rounded p-3 shadow"> <div className="bg-white w-[70%] rounded p-3 shadow">