request create product + category learning

This commit is contained in:
hamid zarghami
2025-10-12 11:38:23 +03:30
parent db6157ae5d
commit 72f84d00b0
10 changed files with 403 additions and 229 deletions
+49
View File
@@ -1,5 +1,9 @@
import * as api from "../service/SellerService";
import { useMutation, useQuery } from "@tanstack/react-query";
import type {
CreateCategoryLearning,
CreateLearningType,
} from "../types/Types";
export const useGetSellers = (page: number = 1, enabled: boolean = true) => {
return useQuery({
@@ -66,3 +70,48 @@ export const useGetRequestCreateProduct = (page: number = 1) => {
queryFn: () => api.getRequestCreateProduct(page),
});
};
export const useGetLearningCategory = () => {
return useQuery({
queryKey: ["learning-category"],
queryFn: () => api.getLearningCategory(),
});
};
export const useCreateLearningCategory = () => {
return useMutation({
mutationFn: api.createLearningCategory,
});
};
export const useUpdateLearningCategory = () => {
return useMutation({
mutationFn: ({
id,
params,
}: {
id: string;
params: CreateCategoryLearning;
}) => api.updateLearningCategory(id, params),
});
};
export const useGetLearning = () => {
return useQuery({
queryKey: ["learning"],
queryFn: () => api.getLearning(),
});
};
export const useCreateLearning = () => {
return useMutation({
mutationFn: api.createLearning,
});
};
export const useUpdateLearning = () => {
return useMutation({
mutationFn: ({ id, params }: { id: string; params: CreateLearningType }) =>
api.updateLearning(id, params),
});
};