import { T_blogs } from "@/types/blogs.type";
import axiosInstance from "../axiosInstance";

export interface IBlogQueryParams {
    [key: string]: string | number | boolean | undefined;
}


export const blogService = {
    getBlogs: (params?: IBlogQueryParams) =>
        axiosInstance.get("/api/blogs", { params }).then(res => res.data),

    getBlogById: (id: string) =>
        axiosInstance.get(`/api/blogs/${id}`),

    createBlog: (data: Partial<T_blogs>) =>
        axiosInstance.post("/api/blogs", data),

    updateBlog: (id: string, data: Partial<T_blogs>) =>
        axiosInstance.patch(`/api/blogs/${id}`, data),

    deleteBlog: (id: string) =>
        axiosInstance.delete(`/api/blogs/${id}`),
};