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