This commit is contained in:
hamid zarghami
2026-03-09 15:45:36 +03:30
parent eac16c423b
commit 654eefcd3a
2 changed files with 26 additions and 1 deletions
+16 -1
View File
@@ -1,8 +1,23 @@
import * as api from "../service/HomeService";
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";
export const useCreateCatalog = () => {
return useMutation({
mutationFn: api.createCatalog,
});
};
export const useGetCatalog = () => {
return useQuery({
queryKey: ["catalogs"],
queryFn: api.getCatalogs,
});
};
export const useGetCatalogById = (id: string) => {
return useQuery({
queryKey: ["catalog", id],
queryFn: () => api.getCatalogById(id),
enabled: !!id,
});
};
+10
View File
@@ -5,3 +5,13 @@ export const createCatalog = async (params: CreateCatalogParamsType) => {
const { data } = await axios.post("/catalogue", params);
return data;
};
export const getCatalogs = async () => {
const { data } = await axios.get("/catalogue");
return data;
};
export const getCatalogById = async (id: string) => {
const { data } = await axios.get(`/catalogue/${id}`);
return data;
};