web-mikul-news/service/advertisement.ts

43 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-07-02 15:44:00 +00:00
import Cookies from "js-cookie";
2025-07-03 17:18:54 +00:00
import { httpDeleteInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
import { httpGet } from "./http-config/http-base-services";
2025-07-02 15:44:00 +00:00
const token = Cookies.get("access_token");
export async function createAdvertise(data: any) {
const pathUrl = `/advertisement`;
2025-07-03 17:18:54 +00:00
return await httpPostInterceptor(pathUrl, data);
2025-07-02 15:44:00 +00:00
}
export async function createMediaFileAdvertise(id: string | number, data: any) {
const headers = {
"content-type": "multipart/form-data",
};
const pathUrl = `/advertisement/upload/${id}`;
2025-07-03 17:18:54 +00:00
return await httpPostInterceptor(pathUrl, data, headers);
2025-07-02 15:44:00 +00:00
}
export async function getAdvertise(data: any) {
2025-07-03 17:18:54 +00:00
const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${data?.limit || ""}&placement=${data?.placement || ""}&isPublish=${data.isPublish || ""}`;
return await httpGet(pathUrl);
2025-07-02 15:44:00 +00:00
}
2025-07-03 17:18:54 +00:00
export async function getAdvertiseById(id: number) {
2025-07-02 15:44:00 +00:00
const pathUrl = `/advertisement/${id}`;
2025-07-03 17:18:54 +00:00
return await httpGet(pathUrl);
2025-07-02 15:44:00 +00:00
}
export async function editAdvertise(data: any) {
const pathUrl = `/advertisement/${data?.id}`;
2025-07-03 17:18:54 +00:00
return await httpPutInterceptor(pathUrl, data);
2025-07-02 15:44:00 +00:00
}
export async function editAdvertiseIsActive(data: any) {
const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`;
2025-07-03 17:18:54 +00:00
return await httpPutInterceptor(pathUrl, data);
2025-07-02 15:44:00 +00:00
}
export async function deleteAdvertise(id: number) {
const pathUrl = `/advertisement/${id}`;
2025-07-03 17:18:54 +00:00
return await httpDeleteInterceptor(pathUrl);
2025-07-02 15:44:00 +00:00
}