import { useQuery } from "@tanstack/react-query";
import * as api from "../service/MenuService";
import { useParams } from "next/navigation";

export const useGetProducts = () => {
  const { name } = useParams<{ name: string }>();
  return useQuery({
    queryKey: ["menu"],
    queryFn: () => api.getProducts(name),
    enabled: !!name,
  });
};

export const useGetCategories = () => {
  const { name } = useParams<{ name: string }>();
  return useQuery({
    queryKey: ["categories"],
    queryFn: () => api.getCategories(name),
    enabled: !!name,
  });
};

export const useGetNotificationsCount = () => {
  return useQuery({
    queryKey: ["notifications-count"],
    queryFn: api.getNotificationsCount,
  });
};
