29 lines
713 B
TypeScript
29 lines
713 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import * as api from "../service/MenuService";
|
|
import { useParams } from "next/navigation";
|
|
|
|
export const useGetFoods = () => {
|
|
const { name } = useParams<{ name: string }>();
|
|
return useQuery({
|
|
queryKey: ["menu"],
|
|
queryFn: () => api.getFoods(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,
|
|
});
|
|
};
|