68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import axios from "../../../config/axios";
|
|
import { CreateBlogCategoryType, CreateBlogType } from "../types/BlogTypes";
|
|
|
|
export const getBlogCategories = async () => {
|
|
const { data } = await axios.get("/blogs/categories/list");
|
|
return data;
|
|
};
|
|
|
|
export const createBlogCategory = async (params: CreateBlogCategoryType) => {
|
|
const { data } = await axios.post("/blogs/categories", params);
|
|
return data;
|
|
};
|
|
|
|
export const updateBlogCategory = async (
|
|
id: string,
|
|
params: CreateBlogCategoryType
|
|
) => {
|
|
const { data } = await axios.patch(`/blogs/categories/${id}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const deleteBlogCategory = async (id: string) => {
|
|
const { data } = await axios.delete(`/blogs/categories/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const getBlogCategoryDetail = async (id: string) => {
|
|
const { data } = await axios.get(`/blogs/categories/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const getBlogs = async (search: string, page: number) => {
|
|
const { data } = await axios.get(`/blogs/list?q=${search}&page=${page}`);
|
|
return data;
|
|
};
|
|
|
|
export const getBlogDetail = async (id: string) => {
|
|
const { data } = await axios.get(`/blogs/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const createBlog = async (params: CreateBlogType) => {
|
|
const { data } = await axios.post("/blogs", params);
|
|
return data;
|
|
};
|
|
|
|
export const updateBlog = async (id: string, params: CreateBlogType) => {
|
|
const { data } = await axios.patch(`/blogs/${id}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const deleteBlog = async (id: string) => {
|
|
const { data } = await axios.delete(`/blogs/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const getBlogComments = async () => {
|
|
const { data } = await axios.get("/blogs/comments");
|
|
return data;
|
|
};
|
|
|
|
export const changeStatusComment = async (id: string, status: string) => {
|
|
const { data } = await axios.patch(`/blogs/comments/${id}/status`, {
|
|
status,
|
|
});
|
|
return data;
|
|
};
|