2026-03-18 14:25:08 +05:30
|
|
|
import apiClient from "@/api/client";
|
|
|
|
|
|
|
|
|
|
export interface Blog {
|
|
|
|
|
id?: number;
|
|
|
|
|
title: string;
|
|
|
|
|
writer: string;
|
|
|
|
|
image?: string;
|
|
|
|
|
content: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getAllBlogsApi = async () => {
|
|
|
|
|
const res = await apiClient.get("/blogs");
|
|
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getBlogByIdApi = async (id: number) => {
|
2026-04-14 16:04:44 +05:30
|
|
|
const res = await apiClient.get(`/blogs/admin/${id}`);
|
2026-03-18 14:25:08 +05:30
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createBlogApi = async (data: Blog) => {
|
|
|
|
|
const res = await apiClient.post("/blogs", data);
|
|
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateBlogApi = async (id: number, data: Blog) => {
|
|
|
|
|
const res = await apiClient.put(`/blogs/${id}`, data);
|
|
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteBlogApi = async (id: number) => {
|
|
|
|
|
const res = await apiClient.delete(`/blogs/${id}`);
|
|
|
|
|
return res.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* IMAGE UPLOAD */
|
|
|
|
|
export const uploadImageApi = async (file: File) => {
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("image", file);
|
|
|
|
|
|
|
|
|
|
const res = await apiClient.post("/upload/image", formData, {
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "multipart/form-data",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return res.data;
|
|
|
|
|
};
|