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