44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { prisma } from "@/app/lib/prisma";
|
||
import MenuView from "./components/MenuView";
|
||
|
||
export const dynamic = 'force-dynamic';
|
||
|
||
export default async function Page() {
|
||
const restaurant = await prisma.restaurant.findFirst({
|
||
include: {
|
||
categories: {
|
||
include: {
|
||
items: true,
|
||
},
|
||
orderBy: {
|
||
createdAt: 'asc',
|
||
},
|
||
},
|
||
},
|
||
});
|
||
|
||
if (!restaurant) {
|
||
return <div>Veritabanı yükleniyor...</div>;
|
||
}
|
||
|
||
// Map database structure to the structure expected by MenuView
|
||
const data = {
|
||
restaurant_name: restaurant.name,
|
||
footer_note: restaurant.footerNote || "",
|
||
categories: restaurant.categories.map(cat => ({
|
||
id: cat.id,
|
||
title: cat.title,
|
||
externalId: cat.externalId,
|
||
items: cat.items.map(item => ({
|
||
name: item.name,
|
||
ingredients: item.ingredients,
|
||
tasteProfile: item.tasteProfile,
|
||
grapeVariety: item.grapeVariety,
|
||
price: item.price,
|
||
})),
|
||
})),
|
||
};
|
||
|
||
return <MenuView data={data} />;
|
||
}
|