slider
This commit is contained in:
@@ -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),
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -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: [] };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user