2025-01-21 07:31:30 +00:00
|
|
|
import { PaginationRequest } from "@/types/globals";
|
2025-01-20 12:10:04 +00:00
|
|
|
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 createMagazine(data: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${token}`,
|
|
|
|
|
};
|
|
|
|
|
const pathUrl = `/magazines`;
|
|
|
|
|
return await httpPost(pathUrl, headers, data);
|
|
|
|
|
}
|
2025-01-21 07:31:30 +00:00
|
|
|
|
|
|
|
|
export async function getListMagazine(props: PaginationRequest) {
|
|
|
|
|
const { page, limit, search, startDate, endDate } = props;
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpGet(
|
|
|
|
|
`/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${
|
|
|
|
|
startDate || ""
|
|
|
|
|
}&endDate=${endDate || ""}`,
|
|
|
|
|
headers
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-01-21 08:46:31 +00:00
|
|
|
|
|
|
|
|
export async function updateMagazine(id: string, data: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
2025-08-29 06:43:53 +00:00
|
|
|
Authorization: `Bearer ${token}`,
|
2025-01-21 08:46:31 +00:00
|
|
|
};
|
|
|
|
|
const pathUrl = `/magazines/${id}`;
|
|
|
|
|
return await httpPut(pathUrl, headers, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getMagazineById(id: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpGet(`/magazines/${id}`, headers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteMagazine(id: string) {
|
2025-03-18 08:30:18 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
2025-08-29 06:43:53 +00:00
|
|
|
Authorization: `Bearer ${token}`,
|
2025-03-18 08:30:18 +00:00
|
|
|
};
|
|
|
|
|
return await httpDeleteInterceptor(`magazines/${id}`, headers);
|
2025-01-21 08:46:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function uploadMagazineFile(id: string, data: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "multipart/form-data",
|
2025-08-29 06:43:53 +00:00
|
|
|
Authorization: `Bearer ${token}`,
|
2025-01-21 08:46:31 +00:00
|
|
|
};
|
|
|
|
|
return await httpPost(`/magazine-files/${id}`, headers, data);
|
|
|
|
|
}
|
2025-01-21 11:20:58 +00:00
|
|
|
|
2025-01-23 15:30:33 +00:00
|
|
|
export async function uploadMagazineThumbnail(id: string, data: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "multipart/form-data",
|
2025-08-29 06:43:53 +00:00
|
|
|
Authorization: `Bearer ${token}`,
|
2025-01-23 15:30:33 +00:00
|
|
|
};
|
|
|
|
|
return await httpPost(`/magazines/thumbnail/${id}`, headers, data);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 11:20:58 +00:00
|
|
|
export async function deleteMagazineFiles(id: number) {
|
2025-03-18 08:30:18 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "multipart/form-data",
|
2025-08-29 06:43:53 +00:00
|
|
|
Authorization: `Bearer ${token}`,
|
2025-03-18 08:30:18 +00:00
|
|
|
};
|
|
|
|
|
return await httpDeleteInterceptor(`magazine-files/${id}`, headers);
|
2025-01-21 11:20:58 +00:00
|
|
|
}
|