update optimize
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-06-06 15:06:19 +03:30
parent c9d152fbaf
commit 804f6f69ae
8 changed files with 103 additions and 20 deletions
@@ -5,7 +5,7 @@ import { useParams } from "next/navigation";
export const useGetAbout = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
queryKey: ["about"],
queryKey: ["about", name],
queryFn: () => api.getAbout(name),
enabled: !!name,
retry: false,
@@ -17,7 +17,7 @@ export const useGetAbout = () => {
export const useGetReviews = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
queryKey: ["reviews"],
queryKey: ["reviews", name],
queryFn: () => api.getReviews(name),
enabled: !!name,
retry: false,
@@ -27,7 +27,7 @@ export const useGetReviews = () => {
export const useGetSchedules = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
queryKey: ["schedules"],
queryKey: ["schedules", name],
queryFn: () => api.getSchedules(name),
enabled: !!name,
retry: false,
+4 -2
View File
@@ -6,7 +6,7 @@ import { hasAuthToken } from "@/lib/api/func";
export const useGetFoods = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
queryKey: ["menu"],
queryKey: ["menu", name],
queryFn: () => api.getFoods(name),
enabled: !!name,
staleTime: 5 * 60_000,
@@ -17,9 +17,11 @@ export const useGetFoods = () => {
export const useGetCategories = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
queryKey: ["categories"],
queryKey: ["categories", name],
queryFn: () => api.getCategories(name),
enabled: !!name,
staleTime: 5 * 60_000,
refetchOnMount: false,
});
};
+11 -3
View File
@@ -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>
);
}