create product

This commit is contained in:
hamid zarghami
2026-01-24 15:38:17 +03:30
parent 54eb477200
commit cb174bf0dc
11 changed files with 261 additions and 43 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import * as api from "../service/ProductService";
import type { CreateCategoryType } from "../types/Types";
@@ -35,3 +35,22 @@ export const useGetCategoryDetail = (id: string) => {
enabled: !!id,
});
};
export const useGetProducts = () => {
return useQuery({
queryKey: ["products"],
queryFn: api.getCategory,
});
};
export const useCreateProduct = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: api.createProduct,
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["products"],
});
},
});
};