This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getRestaurant } from "@/app/[name]/lib/getRestaurant";
|
||||
import {
|
||||
buildRestaurantMetadata,
|
||||
buildRestaurantViewport,
|
||||
} from "@/app/[name]/lib/restaurantMetadata";
|
||||
import { prefetchMenuPageData } from "@/app/[name]/lib/prefetchMenuPage";
|
||||
import { getQueryClient } from "@/lib/query/getQueryClient";
|
||||
import MenuIndex from "./components/MenuIndex";
|
||||
|
||||
type PageParams = { name: string };
|
||||
@@ -33,14 +35,20 @@ export default async function Page({
|
||||
params: Promise<PageParams>;
|
||||
}) {
|
||||
const { name } = await params;
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
try {
|
||||
await getRestaurant(name);
|
||||
await prefetchMenuPageData(queryClient, name);
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === "RESTAURANT_NOT_FOUND") {
|
||||
notFound();
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
return <MenuIndex />;
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<MenuIndex />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user