32 lines
864 B
TypeScript
32 lines
864 B
TypeScript
import axios from "@/config/axios";
|
|
import type {
|
|
CreateCatalogParamsType,
|
|
UpdateCatalogParamsType,
|
|
} from "../types/Types";
|
|
import type {
|
|
CatalogByIdResponseType,
|
|
CatalogResponseType,
|
|
} from "@/pages/catalogue/types/Types";
|
|
|
|
export const createCatalog = async (params: CreateCatalogParamsType) => {
|
|
const { data } = await axios.post("/catalogue", params);
|
|
return data;
|
|
};
|
|
|
|
export const getCatalogs = async () => {
|
|
const { data } = await axios.get<CatalogResponseType>("/catalogue");
|
|
return data;
|
|
};
|
|
|
|
export const getCatalogById = async (id: string) => {
|
|
const { data } = await axios.get<CatalogByIdResponseType>(`/catalogue/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const updateCatalog = async (params: UpdateCatalogParamsType) => {
|
|
const { data } = await axios.patch(`/catalogue/${params.id}`, {
|
|
content: params.content,
|
|
});
|
|
return data;
|
|
};
|