update category

This commit is contained in:
hamid zarghami
2026-01-24 12:15:41 +03:30
parent 3dc13d1830
commit 4a728ad676
8 changed files with 190 additions and 7 deletions
+16
View File
@@ -1,5 +1,6 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/ProductService";
import type { CreateCategoryType } from "../types/Types";
export const useGetCategory = () => {
return useQuery({
@@ -19,3 +20,18 @@ export const useDeleteCategory = () => {
mutationFn: (id: string) => api.deleteCategory(id),
});
};
export const useUpdateCategory = () => {
return useMutation({
mutationFn: ({ id, params }: { id: string; params: CreateCategoryType }) =>
api.updateCategory(id, params),
});
};
export const useGetCategoryDetail = (id: string) => {
return useQuery({
queryKey: ["category", id],
queryFn: () => api.getCategoryDetail(id),
enabled: !!id,
});
};