services
This commit is contained in:
@@ -1,8 +1,23 @@
|
|||||||
import * as api from "../service/HomeService";
|
import * as api from "../service/HomeService";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
export const useCreateCatalog = () => {
|
export const useCreateCatalog = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: api.createCatalog,
|
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,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -5,3 +5,13 @@ export const createCatalog = async (params: CreateCatalogParamsType) => {
|
|||||||
const { data } = await axios.post("/catalogue", params);
|
const { data } = await axios.post("/catalogue", params);
|
||||||
return data;
|
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;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user