import { PaginationRequest } from "@/types/globals"; import { httpDeleteInterceptor, httpGet, httpPost, httpPut, } from "./http-config/axios-base-service"; import Cookies from "js-cookie"; const token = Cookies.get("access_token"); export async function getListArticle(props: PaginationRequest) { const { page, limit, search, startDate, endDate } = props; const headers = { "content-type": "application/json", }; return await httpGet( `/articles?limit=${limit}&page=${page}&title=${search}&startDate=${ startDate || "" }&endDate=${endDate || ""}`, headers ); } export async function createArticle(data: any) { const headers = { "content-type": "application/json", Authorization: `Bearer ${token}`, }; const pathUrl = `/articles`; return await httpPost(pathUrl, headers, data); } export async function updateArticle(id: any) { const headers = { "content-type": "application/json", }; const pathUrl = `/articles/${id}`; return await httpPut(pathUrl, headers); } export async function getArticleById(id: any) { const headers = { "content-type": "application/json", }; return await httpGet(`/articles/${id}`, headers); } export async function deleteArticle(id: string) { return await httpDeleteInterceptor(`articles/${id}`); } export async function getArticleByCategory() { const headers = { "content-type": "application/json", }; return await httpGet(`/article-categories?limit=50`, headers); }