This commit is contained in:
hamid zarghami
2026-07-04 10:15:30 +03:30
parent 5921ac0bc7
commit 136acf1f4c
9 changed files with 279 additions and 7 deletions
+5
View File
@@ -3,6 +3,7 @@ import {
fetchAboutResponse,
fetchCategoriesResponse,
fetchFoodsResponse,
fetchSlidersResponse,
} from "./serverMenuFetch";
export async function prefetchMenuPageData(
@@ -22,5 +23,9 @@ export async function prefetchMenuPageData(
queryKey: ["categories", name],
queryFn: () => fetchCategoriesResponse(name),
}),
queryClient.prefetchQuery({
queryKey: ["sliders", name],
queryFn: () => fetchSlidersResponse(name),
}),
]);
}
+19 -1
View File
@@ -1,7 +1,11 @@
import axios from "axios";
import { API_BASE_URL } from "@/config/const";
import type { AboutResponse } from "../(Main)/about/types/Types";
import type { CategoriesResponse, FoodsResponse } from "../(Main)/types/Types";
import type {
CategoriesResponse,
FoodsResponse,
SlidersResponse,
} from "../(Main)/types/Types";
import { getRestaurant, RESTAURANT_FETCH_TIMEOUT_MS } from "./getRestaurant";
function createServerAxios(slug: string) {
@@ -37,3 +41,17 @@ export async function fetchCategoriesResponse(
);
return data;
}
export async function fetchSlidersResponse(
slug: string,
): Promise<SlidersResponse> {
try {
const client = createServerAxios(slug);
const { data } = await client.get<SlidersResponse>(
`/public/sliders/restaurant/${slug}`,
);
return data;
} catch {
return { success: true, data: [] };
}
}