import type { QueryClient } from "@tanstack/react-query";
import {
  fetchAboutResponse,
  fetchCategoriesResponse,
  fetchFoodsResponse,
  fetchSlidersResponse,
} from "./serverMenuFetch";

export async function prefetchMenuPageData(
  queryClient: QueryClient,
  name: string,
) {
  await Promise.all([
    queryClient.prefetchQuery({
      queryKey: ["about", name],
      queryFn: () => fetchAboutResponse(name),
    }),
    queryClient.prefetchQuery({
      queryKey: ["menu", name],
      queryFn: () => fetchFoodsResponse(name),
    }),
    queryClient.prefetchQuery({
      queryKey: ["categories", name],
      queryFn: () => fetchCategoriesResponse(name),
    }),
    queryClient.prefetchQuery({
      queryKey: ["sliders", name],
      queryFn: () => fetchSlidersResponse(name),
    }),
  ]);
}
